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 Basics (2014) Basic Layout Clearing Floats

Vanessa Elliott
Vanessa Elliott
1,742 Points

What does he mean by Pseudo-Element?

I don't understand what a Pseudo-Element is. I tried to look it up, and the definition made no sense to me... So it's really hard to understand what he's talking about in terms of this clearfix adding pseudo-elements or whatever...

I'm also struggling with the <span> tag. What the heck does span do? I feel pretty confident that I understand all the other html tags we've covered in this course so far, but that one just seems to have no actual purpose. This was an old question I had from a few videos back that I forgot to ask about.

Thank you for any help you can provide!

2 Answers

David Bath
David Bath
25,940 Points

A span is just a generic container element similar to div, but where a div by default has display: block a span is display:inline. There are many uses for this element. You could use it as a wrapper for certain words inside a paragraph that you want to style differently, for example.

A pseudo-element is a little harder to grasp. It is generated purely by the CSS, but can be styled like any element. For instance, the :after pseudo-element (like .container:after) will generate an element that appears inside the container that it is applied to, but after any other content. So the "clearfix" technique is creating one of these pseudo-elements inside a container that also contains floated elements. The floated elements allow the container's height to "collapse", but appending a pseudo-element with certain properties inside the container after the floated element can cause the container to retain its height.

Vanessa Elliott
Vanessa Elliott
1,742 Points

Thank you for explaining Span to me! That makes a lot more sense now.

As for the pseudo-element thing, what I think you're saying is that a pseudo element isn't exactly an entirely new element of its own, it just applies additional parameters to one? So like if .p is targeting paragraphs, and you applied one of these pseudo-elements to it like... .p::first-letter (no idea what that does, just found it as an example on google) the ::first-letter is the pseudo-element?

Sorry for replying like, 3 days later. I've been out of town.

David Bath
David Bath
25,940 Points

Well, sort of... with first-letter it's really targeting part of the existing markup, the "first letter" of text in that p element. It's as if you surrounded that first letter with <span> tags and styled that span! ::before or ::after are different because they actually do create a new element, though you won't see it in the HTML.

Vanessa Elliott
Vanessa Elliott
1,742 Points

Ahhh okay. I re-watched the video and I understood what he was saying now. Thank you again!