HTML and CSS Reference
In-Depth Information
Including Styles in Tags
You've already seen how HTML pages are created using tags. I want to stop briefly and
discuss attributes, as well. An attribute is an additional bit of information that somehow
affects the behavior of a tag. Attributes are included inside the opening tag in a pair.
Here's an example:
<tag attribute =” value ”>
Some attributes can be used with nearly any tag; others are highly specific. One attribute
that can be used with nearly any tag is style . By including the style attribute in a tag,
you can include one or more style rules within a tag itself. Here's an example using the
<h1> tag, which I introduced earlier:
< h1 style =”font-family: Verdana, sans-serif;”>Heading< /h1 >
The style attribute of the <h1> tag contains a style declaration. All style declarations
follow this same basic pattern, with the property on the left and the value associated with
that property on the right. The rule ends with a semicolon, and you can include more
than one in a style attribute by placing commas between them. If you're only including
one rule in the style attribute, the semicolon is optional, but it's a good idea to include
it. In the preceding example, the property is font-family , and the value is Verdana,
sans-serif . This attribute modifies the standard <h1> tag by changing the font to
Verdana, and if the user doesn't have that font installed on his system, whichever sans-
serif font the browser selects. (Sans-serif fonts are those that do not include serifs , the
small lines at the ends of characters.)
Many, many properties can be used in style declarations. As previously mentioned,
putting a declaration into a style attribute is just one of several ways that you can apply
styles to your document.
Programs to Help You Write HTML
You might be thinking that all this tag stuff is a real pain, especially if you didn't get that
small example right the first time. (Don't fret about it; I didn't get that example right the
first time, and I created it.) You have to remember all the tags, and you have to type them
in right and close each one. What a hassle!
Many freeware and shareware programs are available for editing HTML files. Most of
these programs are essentially text editors with extra menu items or buttons that insert
the appropriate HTML tags into your text. HTML-based text editors are particularly nice
for two reasons: You don't have to remember all the tags, and you don't have to take the
time to type them all. I've already mentioned HTML-Kit, but there are plenty of others.
 
 
Search WWH ::




Custom Search