Difference between revisions of "ID selector (CSS)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "In CSS, an '''ID rule''' (or '''ID style rule''', or '''ID style''') is a style rule which selects zero or one HTML element based on the element's ID attribute (...")
 
(Example)
Line 11: Line 11:
 
ID style rule:
 
ID style rule:
  
<code>#example { color: red}</code>
+
<pre>#example { color: red}</pre>
  
 
Element affected by rule:
 
Element affected by rule:
  
<code>
+
<pre>
 
<div id="example">...</div>
 
<div id="example">...</div>
</code>
+
</pree>
  
 
In the above example, <code>div</code> is an arbitrary HTML element.  Any other type of HTML element works the same.
 
In the above example, <code>div</code> is an arbitrary HTML element.  Any other type of HTML element works the same.

Revision as of 11:13, 9 February 2016

In CSS, an ID rule (or ID style rule, or ID style) is a style rule which selects zero or one HTML element based on the element's ID attribute.

Description

An ID rule must apply exactly one HTML element on a page (or no HTML element at all).

No two HTML elements on a given web page may have the same value for their ID attributes.

Example

ID style rule:

#example { color: red}

Element affected by rule:

<div id="example">...</div>
</pree>

In the above example, <code>div</code> is an arbitrary HTML element.  Any other type of HTML element works the same.

== See also ==

* [[Cascading Style Sheets]]
* [[ID rule (CSS)]]
* [[Style sheet (web design)]]