Master useful CSS pseudo-elements

Pseudo Elements in CSS enable the developers to style parts of an element, giving them the granular access to styling. In this article, we will cover some lesser used but pretty useful Pseudo Elements, which can help you CSS game to the next level!

Selection

The ::selection CSS pseudo-element styles the part of a document that is selected by a user (such as clicking and dragging the mouse across text to highlight it).

Marker

The ::marker CSS pseudo-element selects the marker box of a list item and generally contains a bullet or number. It works on any element or pseudo-element where the display property is set to list-item ( display: list-item), such as <li> elements.

Placeholder

The ::placeholder CSS pseudo-element can be used to target the placeholder text in an <input> or <textarea> element.

Slotted()

The ::slotted() CSS pseudo-element represents any element that has been placed into a slot inside an HTML template.

This only works when used inside CSS placed within a Shadow DOM. Note also that this selector won’t select a text node placed into a slot, but targets actual elements.

First Line & First Letter

Just as the name suggests, the ::first-line and ::first-letter CSS pseudo-elements applies styles to the first line and the first letter respectively (of a block-level element). In case of ::first-line, the length of the first line depends on many factors, including the width of the element, the width of the document, the font size of the text and may even depend on the screen size. ::first-letter only styles the first letter when not preceded by other content (such as images or inline tables).

Research says, writing down your goals on pen & paper makes you 21% to 39% more likely to achieve them. Check out these notebooks and journals to make the journey of achieving your dreams easier: https://www.amazon.com/Tapajyoti-Bose/e/B09VGDDHRR

Need a Top Rated Front-End Development Freelancer to chop away your development woes? Contact me on Upwork

Want to see what I am working on? Check out my Personal Website and GitHub

Want to connect? Reach out to me on LinkedIn

Originally published at https://dev.to on March 7, 2021.

--

--

Top Rated Freelancer || Blogger || Cross-Platform App Developer || Web Developer || Open Source Contributor || FIRE Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tapajyoti Bose

Tapajyoti Bose

Top Rated Freelancer || Blogger || Cross-Platform App Developer || Web Developer || Open Source Contributor || FIRE Enthusiast