Targeting Elements to Format with Selectors

The property:value; pair is fairly easy to understand. All you’re doing is naming a property (characteristic) of the element and then specifying its format. The trickier part is dealing with selectors because you can use four different types of selectors:
• Tag
• Class
• ID
• Attribute
The following sections explain each type of selector in greater detail.

Tag Selectors

The concept of tag selectors is the easiest to grasp. You simply use the tag without the angle brackets to specify the HTML element you want the style rule to target; for example p for paragraphs, img for images, h1 for level 1 headings, and so on. Using tag selectors, you can apply identical formatting to all instances of a particular ...

Get The Complete Idiot's Guide® To HTML5 and CSS3 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.