From the course: CSS Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

ID selectors

ID selectors

- [Instructor] Unlike a type or universal selector, which can match to multiple elements on a page, an ID selector matches to a single unique element. To use an ID selector, an ID attribute must first be added to the elements opening tag. ID equals a value in quotes. The value is defined by you. The value is then used as the CSS selector starting with a number sign. When choosing an ID name, don't include any spaces. If you want to separate multiple words, use in underscore or dash. Camel case where each new word is capitalized is also valid. But using lowercase letters is a more common writing style in CSS. Also using descriptive names that explain the purpose of the style can make it easier to read, and understand why it's being used. For example, an ID name like Global Header implies that the styles are for a header used throughout the website. Let's open another CodePen example. To add a style to…

Contents