CSS Selectors - Smartoolz

CSS Selectors

What are Selectors?

CSS selectors are used to select HTML elements that you want to style.

Types of Selectors:

Element selector, ID selector, and Class selector.

CSS Selectors Example
p {
    color: red;
}

#title {
    color: royalblue;
    text-align: center;
}

.box {
    background: lightyellow;
    padding: 10px;
}
Try it Yourself
Element
ID
Class

Summary

  • Selectors are used to target HTML elements
  • Element, ID and Class are most common
  • They control styling in CSS