![]() |
Other Style Information |
|
|
|
This lesson:
Class | DIV | SPAN
Other lessons: Style Syntax | Order of
Precedence | Style Properties |
Other Style Information
Intro. to Styles | Inline Styles | Embedded Style Sheets |
Linked Style Sheets
A class is used to create variations for a base tag (like the P tag). In other words, the same type of element can have a different style.
.
.
.
<STYLE>
<!--
H1.redtext { color: red }
P.boldgreen { font-weight: bold; color: green }
-->
</STYLE>
.
.
.
<H1 CLASS="redtext">Example</H1>
<P CLASS="boldgreen">This line is boldfaced and green.</P>
<P>This text is unaffected by any styles.</P>
<STYLE>
<!--
.greentext { color: green }
.book { font-style: italic }
-->
</STYLE>
<H1 CLASS="greentext">Book List</H1>
<P CLASS="greentext">Charles Shultz</P>
<P CLASS="book">Snoopy and Friends</P>
<P>This is a story about Snoopy and his friends.</P>
If you want to change the look of a large block of text on a page, use the DIV tag.
<DIV STYLE="font-size: 14pt; color: red">
<P>The cicada has a lifecycle of 17 years.</P>
<P>It is the subject of many myths dating back thousands of years.>/P>
</DIV>
<DIV CLASS="definition">
<H1>The Cicada</H1>
<P>The cicada has a lifecycle of <B>17</B> years. It is the subject of
many myths dating back thousands of years.</P>
</DIV>
If you want to change the look for a small quantity of text, use the SPAN tag.
The lifecycle of the <SPAN STYLE="background-color: yellow">cicada</SPAN> is unlike any other in the insect world.
The lifecycle of the <SPAN CLASS="highlight">cicada</SPAN> is unlike any other in the insect world.
- This example would render the word, cicada, with a yellow background if .highlight {background-color: yellow } is defined in a style sheet.
- Example: This web page has a class called .code which is defined in the embedded style sheet. This class is designed to apply a Courier font of 12 points to text. The bulleted line above uses the SPAN tags. Use your browser to view the HTML for this web page.
![]()
Penn State Behrend Home | Computer Center Home
This page is maintained by Carolyn Dudas
Updated May 21, 2002