microsoft.com Home   All Products  |   Support  |   Search  |   microsoft.com Home  
Microsoft

Microsoft Typography | Typography on the Web | Specifying fonts... | CLASS next


CLASS

CLASS is a new attribute. All BODY elements can be classed, and the CLASS can be addressed in the style sheet. Within the style sheet classes are defined in the same way as normal HTML tags, however to distinguish them they are preceded by a period.

.seaside { color: blue; background: yellow }

For example within a document or site you may want to create a number of different styles for paragraph text. You may not want to indent opening paragraphs, and on certain pages you may require larger paragraph text. These could be defined in the following way;

P      { text-indent: 2pc }
.first { text-indent: 0pc; font-weight: bold }
.large { font-size: 120% }

And within the BODY these styles would be applied in the following way;

<P CLASS=first>This is the opening paragraph
<P>This is an ordinary paragraph
<P CLASS=large>This paragraph text should be larger

And the following results would be seen on screen;

CLASS demo


Using class with the DIV and SPAN tags

As well as using CLASS to customize existing HTML tags it can be used to create what, in effect, are new tags. To create a new block level tag the following could be defined within the STYLE section of the HTML document;

P      { font-size: 10pt;
         line-height: 13pt;
         text-indent: 2pc;
         font-family: Trebuchet MS }
.first { font-size: 10pt;
         line-height: 13pt;
         font-family: Trebuchet MS }

Within the document ordinary paragraph text is tagged in the normal way, but the newly defined class is specified using the DIV HTML tag.

<DIV CLASS=first>This is the opening
paragraph.</DIV>
<P>This is the second paragraph.

New inline elements may be defined in the same way, but are deployed using the SPAN tag.

Ordinary and <SPAN CLASS=wild> highligted </SPAN>

Although this method of defining new tags, can be useful, the main drawback is that content tagged in this way will be displayed as plain text in non-CSS browsers.



this page was last updated 30 June 1997
© 1997 Microsoft Corporation. All rights reserved. Terms of use.
comments to the MST group: how to contact us

 

Microsoft Typography | Typography on the Web | Specifying fonts... | CLASS next