1.

What do you mean by CSS Selectors? Name a Few.

Answer»

<P>CSS selectors are used by web designers to specify or SELECT HTML elements they want to style. FOLLOWING are a few of the most COMMONLY used CSS selectors: 

  • ID Selector: It selects HTML elements using specific id attributes.

Syntax: #idname

Example: Here is the CSS rule that will be applied to the HTML element having id="para1".

#para1 { text-align: left; color: BLUE;}
  • Class Selector: It selects HTML elements using specific class attributes.

Syntax: .classname

Example: Here is the CSS rule that will be applied to the HTML element with class="scaler".

.scaler { text-align: left; color: blue;}
  • Child Selector or Combinator: It selects all HTML elements that are children of the specified element. In a child selector, there are two or more selectors separated by ">".

Syntax: selector1 > selector2

Example: Here is a CSS rule that will be applied to HTML elements (<p>) that are children of a <div> element.

div > p { background-color: blue;}


Discussion

No Comment Found