From the course: CSS Essential Training
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Descendant combinators and selector lists - CSS Tutorial
From the course: CSS Essential Training
Descendant combinators and selector lists
- [Instructor] When writing HTML, tags are nested inside of other tags, which creates a hierarchy known as the Document Object Model or DOM for short. Elements nested at the first level create a parent-child relationship. Deeper levels create an ancestor-descendant relationship. Elements nested within the same parent are sibling elements. Descendant combinators are used to select nested elements by combining two selectors, one targeting an ancestor element, and the other a descendant element. It must be separated by a space. For example, section, space, p will select only paragraphs inside of a section element. Let's open up a CodePen example to see the different ways we can use a descendant combinator. Let's start by uncommenting the color value in the a selector. Delete the slash and asterisk to add the style back in or use the keyboard shortcut, Command or Control + forward slash. This is a type selector, so it will…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
CSS specifications and the W3C3m 12s
-
(Locked)
CSS syntax and terminology4m 2s
-
(Locked)
CSS values and units3m 33s
-
(Locked)
The color property and values4m 31s
-
(Locked)
Creating a color palette1m 52s
-
(Locked)
Type and universal selectors3m 16s
-
(Locked)
ID selectors2m 34s
-
(Locked)
Class selectors3m 17s
-
(Locked)
Descendant combinators and selector lists2m 56s
-
(Locked)
The background property4m 39s
-
(Locked)
Project: Prepping the CSS file4m 5s
-
(Locked)
Project: Adding background styles7m 39s
-
(Locked)
Pseudo-classes and pseudo-elements4m 30s
-
(Locked)
Inheritance and the cascade2m 20s
-
(Locked)
Specificity3m 45s
-
(Locked)
Project: Styling links5m 23s
-
-
-
-
-
-
-