What is CSS selector?

A CSS selectors is used to select HTML elements based on their name,id,class and attribute. It is the part of a CSS rule that actually selects the content we want to style.

Type of CSS selectors

  • Universal Selector
    For Example
    * {
    color: green;
  • Element Type Selector
    For Example
    ul {
    list-style: none;
  • ID Selector
    #container {
    width: 960px;
  • Class Selector
    For Example
    .box {
    padding: 20px;
  • Attribute Selector
    For Example
    input[type="text"] {
    background-color: #444;

Suggest An Answer

No suggestions avaliable!

Related Interview Questions