From the course: CSS Essential Training
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Pseudo-classes and pseudo-elements
From the course: CSS Essential Training
Pseudo-classes and pseudo-elements
- [Instructor] So far, we've talked about different ways to select one or more elements. With pseudo-class selectors, we can target an element in a specific state. Pseudo-classes are keywords that begin with a colon and are used with another selector. A state can be triggered by a user interaction like a mouse hover, which is styled using the hover pseudo-class. The state of an element can also refer to its structural position in the HTML. For example, first-child targets the first-child element of a specific type defined by the selector it's attached to. There are also pseudo-element selectors, which are used to style a specific part of an element, such as the first letter of a paragraph. They're also combined with a selector, but the keywords start with double colons. Let's look at an example on CodePen. To add a style to the hover state of a link use the hover pseudo-class. Let's uncomment the declarations in the CSS…
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
-
-
-
-
(Locked)
CSS specifications and the W3C2m 35s
-
(Locked)
CSS syntax and terminology3m 29s
-
(Locked)
CSS data types2m 42s
-
(Locked)
Type and universal selectors3m 2s
-
(Locked)
ID selectors1m 53s
-
(Locked)
Class selectors3m 39s
-
(Locked)
Combinators and selector lists3m 3s
-
(Locked)
Pseudo-classes and pseudo-elements3m 22s
-
(Locked)
Inheritance, cascade, and specificity4m 55s
-
(Locked)
Custom properties4m 42s
-
(Locked)
Referencing CSS3m 28s
-
(Locked)
Project: Create a CSS file4m 32s
-
(Locked)
-
-
-
-
-
-
-
-