What Is a ID Selector in CSS?
Submitted by: AdministratorA 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>
Submitted by: Administrator
/* 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>
Submitted by: Administrator
Read Online Cascading Style Sheet CSS Job Interview Questions And Answers
Top Cascading Style Sheet CSS Questions
☺ | What Is the HTML Element Formatting Model in CSS? |
☺ | What Is Inline Element in CSS? |
☺ | What Are the Formatting Behaviors of HTML Elements? |
☺ | What Is a Class Selector in CSS? |
☺ | How To Use Class Selectors to Differentiate Tag Instances in CSS? |
Top Top World Wide Web Categories
☺ | Cascading Style Sheet CSS Interview Questions. |
☺ | HTML5 Interview Questions. |
☺ | Basic Internet Interview Questions. |
☺ | Domain Name System (DNS) Interview Questions. |
☺ | JavaScript Interview Questions. |