IDs

Instead of styling all elements with the same tag, an element can be given an ID which acts as a unique identifier. This ensures that only the element with the ID will be styled.

Key Points

IDs allow for an element to be unique and styled different.

ID selectors start with a #.

Use an ID to style an element

In the below example, there are three paragraphs. One of the paragraphs is assigned an ID and is styled differently from the other two paragraphs.

The CSS rule for an ID starts with a #:

#specialParagraph

HTML

<p>This is a paragraph.</p>

<p>This is another paragraph.</p>

<p id="specialParagraph">This is also a paragraph.</p>

CSS

p{
    color: pink;
}

#specialParagraph{
    color: blue;
}

National 5 Targets

You should be able to explain the use of an ID.

You should be able to implement IDs into your websites.