CSS Basic Selectors
By Lye Heng Foo onThere are various selectors that we could use to select the element(s) in our HTML page. Simple basic CSS selectors are covered in this article. The advanced CSS selectors will be covered in the following article.
There are 4 simple basic CSS Selectors.
Element selector
Select all <p> elements on a page.
p { }
Select all <h1> and <h2> elements on a page.
h1, h2 { }
Class selector
Select all elements with a specific class on a page. (Example with attribute class=”myclass” in the HTML page)
.myclass { }
ID selector
Select all elements with a specific ID on a page. (Example with attribute id=”myid” in the HTML page)
#myid { }
Universal selector
The universal selector (*) selects all HTML elements on the page.
* { }