DEV Community

Cover image for How to put text inside pseudo elements in CSS?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to put text inside pseudo elements in CSS?

Originally posted here!

To put text inside pseudo-elements like :before and :after, you can use the content property in the CSS and pass the text you want to be displayed as a string.

/* Put text in Pseudo element ✅ */
div:after {
  content: "Hello World!";
}
Enter fullscreen mode Exit fullscreen mode

That's it! 🔥

See the above code live in JSBin

Feel free to share if you found this useful 😃.


Top comments (0)

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay