Difference between revisions of "ID selector (CSS)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Description)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
In [[CSS]], an '''ID selector''' (or '''ID style rule''', or '''ID style''') is a [[selector]] which selects zero or one [[HTML element]] based on the element's [[ID attribute (HTML)|ID attribute]].
+
In [[CSS]], an '''ID selector''' (or '''ID style rule''', or '''ID style''') is a [[selector]] which selects an [[HTML element]] based on the element's [[ID attribute (HTML)|ID attribute]].
  
 
== Description ==
 
== Description ==
Line 28: Line 28:
 
* [[Class selector (CSS)]]
 
* [[Class selector (CSS)]]
 
* [[HTML element selector (CSS)]]
 
* [[HTML element selector (CSS)]]
 +
* [[ID attribute (HTML)]]
 
* [[Style sheet (web design)]]
 
* [[Style sheet (web design)]]
 +
 +
[[Category:Cascading Style Sheets]]
 +
[[Category:Web design and development]]

Latest revision as of 19:34, 5 October 2016

In CSS, an ID selector (or ID style rule, or ID style) is a selector which selects an 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>

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

See also