Home >> Tutorials/FAQs >> CSS Tutorials >> Index
CSS Tutorials - What Is an ID Selector
By: FYICenter.com
(Continued from previous topic...)
What Is an ID Selector?
A ID selector selects all HTML tags that matches the id name defined in the tag attribute of
id="id_name". ID selectors are specified with a leading hash like (#id_name).
For example, the following CSS definition uses an ID selector:
/* set text to red to all tags with id="onSale" */
#onSale {color: red}
If you apply the above CSS definition to the following HTML document, you will get two blocks in red,
one from the <p> tag and one from the <pre> tag:
<p>Normal paragraph...</p>
<p id="onSale">Special paragraph...</p>
<pre>Normal pre-formatted text...</pre>
<pre id="onSale">Special pre-formatted text...</pre>
(Continued on next topic...)
- What Is CSS (Cascading Style Sheets)?
- What Is the Basic Unit of CSS?
- How Many Ways to Attach CSS to HTML Documents?
- How To Include CSS Inside an HTML Tag?
- How To Include CSS Inside the HEAD Tag?
- How To Store CSS Definitions in External Files?
- How Many Ways to Select HTML Tag Instances?
- What Is a Class Selector?
- What Is an ID Selector?
- What Is a Contextual Selector?
- What Is a Group Selector?
- What Is a Mixed Selector?
- What Are the Pseudo Classes on <A> Tags?
- How To Group CSS Definitions Together?
- What Is Style Property Inheritance?
- What Is CSS Cascading?
- What Are the CSS Cascading Order Rules?
- How To Remove the Top White Space of Your Web Page?
- How To Set Different Text Fonts Inside Tables?
- How To Use Class Selectors to Differentiate Tag Instances?
- How To Use IDs to Override Classes?
|