• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Managing Style Sheets > 11.1. Assigning Style Sheet Rules to an Element Glo...

Assigning Style Sheet Rules to an Element Globally

NN 4, IE 3

Problem

You want every instance of a given element in a document to be governed by the same style sheet rule.

Solution

Define a style sheet rule in the head portion of your document, assigning the rule to an HTML element name:

<style type="text/css">
<!--
tagName {styleProperty1:value1; styleProperty2:value2; ...}
-->
</style>

For the tagName, specify the name of the tag without its angle brackets. The following example sets the font size and line height of every p element in a document to 14 points and 110% of normal, respectively:

<style type="text/css">
<!--
p {font-size:14pt; line-height:110%}
-->
</style>

Discussion

Style property names come from the long list of Cascading Style Sheet properties available to DHTML-equipped browsers. The <style> tag is not recognized by browsers prior to Navigator 4 or Internet Explorer 3, so the HTML comment pair just inside the tags hides the style sheet rule definition(s) from older browsers (which would otherwise render the rules as body text, even though the style sheets are defined in the head portion of the document). If you don’t worry about ancient browsers, you can omit the comment symbols.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint