Set The Background Color of A Page
Set The Background Color of A Page
Set The Background Color of A Page
<html>
<head>
<style type="text/css">
body
{
background-color:"PINK";
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:"Times New Roman";
font-size:20px;
}
</style>
</head>
<body>
<h1>CSS example!</h1>
<p>This is a paragraph.</p>
</body>
</html>
Set an image as the background of a page
<html>
<head>
<style type="text/css">
body {background-image:url('paper.gif');}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
How to position a background image
<html>
<head>
<style type="text/css">
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
background-position:right top;
margin-right:200px;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>W3Schools background no-repeat, set postion example.</p>
<p>Now the background image is only show once, and positioned away from the text.</p>
<p>In this example we have also added a margin on the right side, so the background image will never disturb the
text.</p>
</body>
</html>
How to repeat a background image only horizontally
<html>
<head>
<style type="text/css">
body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}
</style>
</head>
<body><h1>Hello World!</h1>
</body>
</html>
fixed background image (this image will not scroll with the rest of the page)
<html>
<head>
<style type="text/css">
body
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
<p>The background-image is fixed. Try
</body>
</html>
to
to
to
to
to
to
to
to
to
scroll
scroll
scroll
scroll
scroll
scroll
scroll
scroll
scroll
down
down
down
down
down
down
down
down
down
the
the
the
the
the
the
the
the
the
page.</p>
page.</p>
page.</p>
page.</p>
page.</p>
page.</p>
page.</p>
page.</p>
page.</p>
<html>
<head>
<style type="text/css">
body {color:red;font-size:20px}
h1 {color:#00ff00;}
p.ex {color:rgb(0,0,255);}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<p>This is an ordinary paragraph. Notice that this text is red. The default text-color for a page is defined in
the body selector.</p>
<p class="ex">This is a paragraph with class="ex". This text is blue.</p>
</body>
</html>
<body>
<p>Link to: <a href="http://www.w3schools.com">W3Schools.com</a></p>
</body>
</html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<p><b>Note:</b> The "blink" value is not supported in IE, Chrome, or Safari.</p>
</body>
</html>
<body>
<p class="uppercase">This is some text.</p>
<p class="lowercase">This is some text.</p>
<p class="capitalize">This is some text.</p>
</body>
</html>
<p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind
ever since. 'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this
world haven't had the advantages that you've had.'</p>
</body>
</html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
</body>
</html>
<p>
This is some text. This is some text.
</p>
</body>
</html>
<body>
<h1>CSS font-family</h1>
<p class="serif">This is a paragraph, shown in the Times New Roman font.</p>
<p class="sansserif">This is a paragraph, shown in the Arial font.</p>
</body>
</html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>This is a paragraph.</p>
</body>
</html>
</body>
</html>
<body>
<p class="normal">This is a paragraph, normal.</p>
<p class="italic">This is a paragraph, italic.</p>
<p class="oblique">This is a paragraph, oblique.</p>
</body>
</html>
<body>
<p class="normal">This is a paragraph.</p>
<p class="light">This is a paragraph.</p>
<p class="thick">This is a paragraph.</p>
<p class="thicker">This is a paragraph.</p>
</body>
</html>
p.ex2
{
font:italic bold 12px/30px Georgia,serif;
}
</style>
</head>
<body>
<p class="ex1">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a
paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p>
<p class="ex2">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a
paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p>
</body>
</html>
COLOR LINK
<html>
<head>
<style type="text/css">
a:link {color:#FF0000;}
/* unvisited link */
a:active {color:#0000FF;}
/* selected link */
</style>
</head>
<body>
<p><b><a href="default.asp" target="_blank">This is a link</a></b></p>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS
definition in order to be effective.</p>
<p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order
to be effective.</p>
</body>
</html>