Attribute Selectors : selector « Style Basics « HTML / CSS






Attribute Selectors

  

Attribute selectors allow you to use the attributes that an element carries in the selector. 


<p id="important" class="XHTML attributes">You must place all attributes
in double quotes.</p>




paragraph[id] matches an element called paragraph carrying an attribute called id

paragraph[id="important"] matches an element called paragraph carrying an attribute called id whose value is important

paragraph[class~="XHTML"] matches an element called paragraph carrying an attribute called class, whose value is a list of space-separated words, one of which is exactly the same as XHTML

paragraph[class|="XHT"] matches an element called paragraph carrying an attribute called class whose value begins with XHT 

   
  








Related examples in the same category

1.Universal Selector
2.The Type Selector
3.The Class Selector
4.The ID Selector
5.The Child Selector
6.The Descendent Selector
7.The Adjacent Sibling Selector
8.Using Attribute Selectors to select different textfields
9.Using Attribute Selectors to choose anchor by link type
10.Using Attribute Selectors to choose only mailto anchor type
11.Using Attribute Selectors to choose linked file type for anchor
12.Using Attribute Selectors to choose php links
13.Using Dynamic Pseudo-Classes to change color
14.Using Dynamic Pseudo-Classes to add text decoration
15.Dynamic Pseudo-Classes: hover effect
16.Selectors and Grouping
17.Class Selectors: A class represents something that you can have more than one of.
18.chain together class names within the class attribute.
19.An id is used but once per document.
20.Universal selectors are wildcard selectors.
21.Descendant Selectors
22.Next Sibling Selectors
23.Attribute Substring Selectors
24.Pseudo-Element Selectors
25.Dynamic Pseudo-Class Selectors
26.Using Different Selectors to Apply Styles
27.First Child Pseudo-Selector
28.Before and After Pseudo Selectors
29.Selector Basics
30.Style sheet for example demonstrating adjacent sibling and child selectors
31.paragraph with id selector
32.Direct Child Selectors
33.A specific selector wins, the last one wins
34.Select one item
35.direct adjacent sibling combinator