Question: Explain in detail the different CSS3 selectors with an example.
0

Subject: Advanced Internet Technology

Topic: Responsive web design with HTML5 and CSS3

Difficulty: Low

ait(26) • 2.1k views
ADD COMMENTlink
modified 15 months ago  • written 17 months ago by gravatar for yamini_patil_28 yamini_patil_28690
0

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).
ADD COMMENTlink
modified 15 months ago  • written 15 months ago by gravatar for yamini_patil_28 yamini_patil_28690
Please log in to add an answer.