Css Note
Css Note
Css Note
h1 {
color: red;}
The selector, h1, indicates that this rule
applies to all h1 headings in the
document. The property that’s being
modified is color, which refers to the font
color. The value we want the color
property to take on is red. Chapter 5 and
Chapter 6 explore fonts and coloring in
CSS in greater detail.
p { font-size: small; color: green;
}
Inline Declarations
You can style any element by listing style
declarations inside that element’s style
attribute. These are referred to as inline
declarations because they’re defined
inline as part of the document’s HTML.
You can assign a style attribute to almost
all HTML elements. For example, to
make a second-level heading within a
document appear in red text and all capital
letters, you could code a line like this:
<h2 style="color: red; text-transform:
uppercase;">An Unusual Heading</h2>
Embedded CSS
Specifying style properties in an
embedded style sheet is an approach
that’s often used by beginning web
designers and those just learning the
techniques involved in CSS design. It’s
not my favorite method, but it does have
the virtue of being easy to deal with, so
you’ll see it used from time to time in this
book. 12 Where can CSS Styles be
Defined?
Background Images
By now, you should feel fairly
comfortable assigning background colors
to elements using the background-color
property, so let’s move on to assigning
background images, which is done with
the background-image property and the
urlfunction, as this markup shows:
body { background-color: white; color:
black; background-image: url(fish.jpg);
}
The url function can be used to specify
any image file, similar to the way you’d
use the img element’s src attribute.
If you define a graphic as the background
for a page—as we have in the example
above—that graphic will repeat, or tile, itself
to fill up the entire browser viewport. As
you scroll through the document, the image
will also scroll along
However, you can use CSS to change both
the tiling and scrolling characteristics of
images. You can define the graphic so that,
rather than tiling, it simply appears once,
wherever you position it. More interestingly,
you can instruct the background graphic to
remain in place while other objects that are
placed on top of it, including text,
effectively scroll over it. 91
body {
background-color: #30293f;
color: white;
background-image: url(fisherman.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right bottom;}