Home > Articles

Selectors in Action

  • Print
  • + Share This
This chapter is from the book

Universal Selectors

Universal selectors are used to select any element. For example, to set the margins and padding on every element to 0, * can be used as shown in Listing 3.9.

Listing 3.9 CSS Code Containing the Universal Selector

*
{
 margin: 0;
 padding: 0;
}

Universal selectors also can be used to select all elements within another element as shown in Listing 3.10. This will select any element inside the <p> element.

Listing 3.10 CSS Code Containing the Universal Selector Within the <p> Element

p *
{
 color: red;
}
  • + Share This
  • 🔖 Save To Your Account