0
3.4kviews
Explain in detail the different CSS3 selectors with an example.

Subject: Advanced Internet Technology

Topic: Responsive web design with HTML5 and CSS3

Difficulty: Low

1 Answer
0
13views

1.Type selector

Selects all elements that match the given node name.

  • Syntax: eltname
  • Example: input will match any <input> element.

2.Class selector

Selects all elements that have the given class attribute.

  • Syntax: .classname
  • Example: .index will match any element that has a class of "index".

3.ID selector

Selects an element based on the value of its id attribute. There should be only one element with a given ID in a document.

  • Syntax: #idname
  • Example: #toc will match the element that has the ID "toc".

4.Universal selector

Selects all elements. Optionally, it may be restricted to a specific namespace or to all namespaces.

  • Syntax: * ns|* |
  • Example: * will match all the elements of the document.

5.Attribute selector

Selects elements based on the value of the given attribute.

  • Syntax: [attr] [attr=value] [attr~=value] [attr|=value] [attr^=value] [attr$=value] [attr*=value]
  • Example: [autoplay] will match all elements that have the autoplay attribute set (to any value).
Please log in to add an answer.