From the course: CSS Positioning Best Practices

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Relating styles to the HTML document with selectors

Relating styles to the HTML document with selectors - CSS Tutorial

From the course: CSS Positioning Best Practices

Relating styles to the HTML document with selectors

selectors are used in CSS to apply a style to elements in the document. For example, this is a selector here, this is the Body selector, this is h1 selector, and these selectors select tags in the XHTML document. So this Body selector will select the body element here and everything within that body element, all the way to the end of tag at the bottom of the document, will be covered by this style and will have this style applied to it. So, that's why the background color is yellow and the text color is brown. This h1 tag applies to all the h1 elements and so these h1 elements have that font to them, because that selector is a tag selector, and it selects all the h1 tags in the document. There's another type of selector here, this is called a class selector, and you see that it has this period at the beginning of it. And that's what makes it a class selector. This is applied by using the class attribute on an element in the document. For example, if I use this class here, I can say…

Contents