We use selectors to target the HTML elements we want to style with CSS. We do this by associating declarations to elements on the web page.
The four basic selectors are:
We use an element selector to select an HTML element by its name. For example, we have a paragraph of text on our HTML page, given below:
Using CSS, we can select this
p element and style it however we like. For example, we may want to change the color of the text to red.
We can do this by targeting the element using the
p selector. This is a simple CSS rule to achieve this would be: