How to put text inside pseudo elements in CSS?

March 10, 2021 - 1 min read

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!";
}

That's it! 🔥

See the above code live in JSBin

Feel free to share if you found this useful 😃.