Skip to main content

Command Palette

Search for a command to run...

Practical Way of Using Pseudo Selector in CSS

Updated
โ€ข2 min read
Practical Way of Using Pseudo Selector in CSS
P

๐Ÿ‘‹ Hey! I'm Prakash Naikwadi. I have a Bachelor's degree in Computer Engineering๐Ÿคฉ

I am currently learning๐Ÿ“˜ ๐Œ๐„๐‘๐ ๐’๐ญ๐š๐œ๐ค ๐ƒ๐ž๐ฏ๐ž๐ฅ๐จ๐ฉ๐ฆ๐ž๐ง๐ญ.

๐Ÿ… ๐†๐ข๐ญ๐‡๐ฎ๐› ๐๐ซ๐จ๐Ÿ๐ข๐ฅ๐ž: https://github.com/prakash-naikwadi

๐‡๐ž๐ซ๐ž ๐š๐ซ๐ž ๐’๐จ๐ฆ๐ž ๐ฌ๐ค๐ข๐ฅ๐ฅ๐ฌ๐ž๐ญ๐ฌ ๐ญ๐ก๐š๐ญ ๐ˆ ๐๐จ๐ฌ๐ฌ๐ž๐ฌ๐ฌ๐ž๐...

๐…๐ซ๐จ๐ง๐ญ ๐„๐ง๐: โ€ข HTML5 (Intermediate Level)
โ€ข CSS (Intermediate Level)
โ€ข JavaScript
โ€ข React

๐๐ซ๐จ๐ ๐ซ๐š๐ฆ๐ฆ๐ข๐ง๐  ๐‹๐š๐ง๐ ๐ฎ๐š๐ ๐ž๐ฌ: โ€ข Java โ€ข C โ€ข C++

Thank you for reading. Have a wonderful day๐Ÿค—

There are a lot of pseudo selectors in CSS & remembering all of them is not possible, but we are going to talk about the most commonly used selectors and most here.

  • LVHA refers to Link, Visited, Hover, and Active pseudo-classes.
  • When we want to design a link or button just select pseudo-classes in LVHA order.
  • This LVHA order is important because if we use the :link after :hover, the :link will override all the properties of hover because they are equally specific.
.btn--full:link,
.btn--full:visited {
  background-color: #e67e22;
  color: #fff;
}

.btn--full:hover,
.btn--full:active {
  background-color: #cf711f;
}

๐Ÿ”ฆ :link
The :link selector is a pseudo-class that targets all anchor <a> elements on a page that have an href attribute.

๐Ÿ”ฆ :visited
The :visited pseudo-class selector can change some of the styling on an anchor link <a> element if the userโ€™s browser has already visited the link.
Itโ€™s meant to help users distinguish the difference between links they have and havenโ€™t visited.

๐Ÿ”ฆ :hover
The :hover pseudo-class in CSS selects elements when the mouse cursor is currently over them. Itโ€™s commonly associated with link <a> elements.

๐Ÿ”ฆ :active
The :active pseudo selector changes the appearance of a link while it is being activated (being clicked on or otherwise activated).
Itโ€™s usually only seen for a split second and provides visual feedback that the element was indeed clicked.

โš’Position and Number-based pseudo-class selectors

Below Are Position and Number-based pseudo selectors

image.png

Reference

https://css-tricks.com/pseudo-class-selectors/

More from this blog

Untitled Publication

9 posts