From the course: HTML & CSS: Creating Forms
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Styling pseudo-classes - HTML Tutorial
From the course: HTML & CSS: Creating Forms
Styling pseudo-classes
- [Instructor] A pseudo-class is a keyword that specifies a state of an element. You can use it to apply styles to an element with that state. There are several pseudo-classes you can use when styling forms. The first are focus and active. Focus is triggered when a user clicks on, tabs, or taps into a field, and active, when a user activates a field, such as by clicking on a button. I'm going to look at applying some different pseudo-classes on this page. So first we're going to try out focus and active. We'll go to our CSS, and after the default styles, we're going to do input:focus, so the style'll apply to any input that's in focus. And give it a background color. And then do an input:active, which will apply to any field that is currently active. And give that a background color, and I'm on line 13. Save, go back to the browser, and now when I tab through the fields, you can see each time I tab to a new field, it gets the green background when it's in focus. As I click in a field…
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.