CSS Selectors

ID Selectors

When we need to style only one element on the page differently, using a class selector is not the best way.

We can use the HTML id attribute to select that single element. The # symbol is used before the id name to select it.

In the above example, the h2 element with the id ‘title’ is affected by the styles. Note that the other h2 elements remain unchanged.