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

11. Managing Style Sheets > 11.3. Assigning Style Sheet Rules to an Individual ...

Assigning Style Sheet Rules to an Individual Element

NN 4, IE 4

Problem

You want a single element to stand out by having its own style sheet rule.

Solution

Define an ID selector for a style rule and assign that same selector name to the id attribute of an element. An ID selector name is preceded by a hash mark (#), as in the following example:

#special {border:5px; border-style:ridge; border-color:red}

This rule applies to the following element:

<div id="special>...</div>

When you create your HTML, assign an identifier to no more than one element on the page. Duplicate identifiers assigned to id attributes of multiple elements just confuse scripts.

Discussion

ID names are entirely up to you, but you should follow the same restrictions for these identifiers as those detailed for class names in


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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