Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Selectors Advanced Selectors Pseudo-Elements - ::before and ::after

Peter Tomasiewicz
Peter Tomasiewicz
5,592 Points

"" for creating empty content that is then defined and styled in css ?

Out of curiosity, a bit of a theoretical question. Guil says that placing content inside quotation marks turns it into strings; just as he showed it on the example of

content: "url('../img/...')"; // website displays the exact same string and not the image.

Why then, when we are creating the content from scratch in css using pseudo classes, we use "" which in theory turn whatever is inside them into strings.

1 Answer

Kevin Korte
Kevin Korte
28,148 Points

It's just part of the CSS spec that in order to have a pusedo element, you have to also have a content attribute, even if it's empty.

Most of the time, my content attribute is empty, just so I can have that extra element for doing some cool effect, like growing a "border" in a way you can actually do with a border attribute.