HTML and CSS Reference
In-Depth Information
EXAMPLE
14.6
<html>
<head><title>Backgrounds</title>
<style type="text/css">
1
body
{
background-image: url('Moonbeams.jpeg');
background-repeat: no-repeat;
background-attachment: fixed
background-color: #ccccff;
background-position:center 80px;
}
2
h2
{
color:white;
font-family:cursive;
font-variant:small-caps;
}
</style>
</head>
3
<body>
4
<h2 align='center'>Looking at Moonbeams</h2>
</body>
</html>
EXPLANATION
1
CSS rules are defined for an HTML selector, the
body
element. The declarations
define the background style of an image called Moonbeams.jpg.
2
The HTML selector is an
h2
element styled to have a white, cursive, font in small caps.
3
The body of the document reflects the CSS rules laid out on line 1.
4
The
h2
tag reflects the font style set by CSS. See Figure 14.7.
Figure 14.7
Background image positioned and nonrepeating.