an ABC of web design Go to Home Page
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The Id of CSS, not Freudianism

I is for the Id selector

Not to be confused with the id of Freudianism, id is a selector in Cascading Style Sheets (CSS).

In CSS the syntax is: selector {property: value}

[Compare with HTML's <element attribute="value">]

The idea is that you select HTML elements and then style them with CSS code either in the header of the page / document or in a separate CSS style sheet (with the extension .css). This is where the selector is declared. It is then called in the body of the document

Unfortunately, for the humble student of CSS there's more than one type of selector: type selectors, class selectors, id selectors, descendant selectors, univeral selectors, and child selectors. And there are also pseudo-classes and pseudo-elements to ponder.

Mostly, I think, you'll be using type, class and id selectors

It's important to keep the following distinction between class and id selectors:

Class selectors can be used more than once in a document, that is, within the body of the document you can call the class that you've declared in the head or external style sheet as many times as you need.

But the id selector should only be used once. So if you've declared a #navbar{ } then you should only call it once in the body <div id="navBar"> which makes sense I hope in this particular example - one that is actually used frequently in CSS layout designs.

Or take the Brighton Quiz by clicking here