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

pat barosy
pat barosy
6,759 Points

Why won't dots show using display:inline?

Hello,

When creating the dots using the before and after pseudo elements, why is it that they only display if we use display: inline-block or display: block.
Why don't they display using display: inline?

Thank you

2 Answers

Steven Parker
Steven Parker
231,248 Points

There's no actual content to display. The circle is actually a rounded background filling the specified height and width. And dimensions are ignored for inline elements, so changing the display to inline causes it to take up no space.

You could use the inline display mode if you have actual content. For example:

h1:before {
  content: "-c-";   /* chosen to approximate roundness */
  display: inline;
  border-radius: 50%;
  color: coral;
  background: coral;
  margin: 0 10px;
}
pat barosy
pat barosy
6,759 Points

Hey Steven, Makes perfect sense. Thank you!!!