We begin by defining a <STYLE> tag in the header of the document. The <STYLE> tag allows you to define the look of an HTML tag. Example:
<HTML> <HEAD> <STYLE type="text/css"> <!-- B { color:red } --> </STYLE> </HEAD> <BODY> This is an example of <B>red text</B>. </BODY> </HTML>Let's examine what this does. After the style definition, notice the HTML comment codes <!-- and -->. This is used so that older browsers won't be confused by the style commands.
Next is the style definition. It begins with the name of the HTML tag to modify (the selector). Then the rules for the modification are contained within the curly braces. In our example, we only have one rule which says to use the color red. Now, whenever you use the <B> tag, the text will be red. See this example.
Later on we'll talk about more styles and properties you can use in your documents. For now, we're going to focus on the basics of how to use it. If you wish to include multiple properties within the same definition, seperate them by semi-colons:
B { color:red; font-style:italic }
![]() Introduction |
Table of Contents |
Next Section
![]() Style 2 |