XHTML deprecates (forbids) the use of attributes in tags such as <font color="...">. Instead, you should define a style in either using internal commands or an external style sheet. Please note that older browsers can't handle style sheets or the <style> tags.
Internal style tags:
<style>
h1 { color : red; font-family : arial; }
p { text-align: center; font-size : 14pt; }
</style>
Embedded styles apply to all the appropriate tags in a page unless a tag overrules them with an inline style. Speaking of which ...
Alternatively, you can add the style="..." attribute to various tags directly, such as <input type="text" style="text-align : center"></input>.
External style sheets:
In this case, xxx.css is the external style sheet (note the .css extension).
<style type="text/css">
@import url(xxx.css)
</style>
At the start of an imported style sheet, you should put the same line:
@import url(xxx.css)
h1 {font-size : 20pt; color : blue; }
p { text-align : center; }
A plain text file showing how each tag is to appear (colour, font size and face etc.) The two standards are CSS1 and CSS2 (has more features). The advantages of using CSS is consistency (all pages in a site can refer to the same CSS file) and ease of updating (to change the appearance of all pages, simply change the CSS file).
|
The tag name to be defined is called the selector. The rest of it (within curly brackets) is the declaration, consisting of the property which is assigned a value. The whole thing is called a rule. Properties are separated from their values by colons (:) and a declaration can include several property + value combinations separated by semicolons (;). |
![]() |
body
{ bgcolor : white; link : blue
}
h2
{ color : red; font-size : 20pt; font-family : times-new-roman
}
The line breaks are optional but are considered good practice.