1.

How to select elements by type, class, and/or ID to style them.

Answer»

Apply styles to chosen class or ID as follows:

  • Use the type SELECTOR to select all ELEMENTS of a particular type. The type selector is the ELEMENT’s name without the less-than and greater-than signs.
  • Use the class selector to select all elements that you have assigned to a class. The class selector is the period followed by the name of a class. The class selector is added to the end of a type selector. You can add it onto the end of the universal selector, *, to select all elements in the document that have a matching class, such as *.my-class1. You can also use the class selector all by itself, such as .my-class1, which is a SHORTCUT for *.my-class1.
  • Use the ID selector to select all elements in the document assigned to that ID. Each element has one ID, which should be UNIQUE in a document.

HTML

  • type { STYLES }
  • *.class { STYLES }
  • #id { STYLES }


Discussion

No Comment Found