Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

css

What is an active selector?

Fahad Farid

An active selector is used to style and select an active link.

It can be used to change the attributessuch as the background color or font size, of a highlighted link once that link has had some action done on it.

The syntax is:

 TAG:action TAG NAME:active{
//enter the properties you want to change
}

The actions can be any acceptable action (e.g., hover or visited). These actions can help with user accessibility. For example, if a link has been visited it will change color to distinguish itself from those links the user has not yet visited.

Here is an example of how this property can be used:

Now, when a user hovers over “Hello and welcome to educative”, it changes color to a yellow background.

In the case of multiple tags in a given file, we can use the class names to distinguish. In that case, we add TAG.Classname:active to make that particular tag active. Here is an example:

In this case, only the “Hello” changes color when a user hovers over the link.

RELATED TAGS

css

CONTRIBUTOR

Fahad Farid
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring