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

Why does Guil specify style: block; in this example?

If I put "style: inline" the code functions the same. Just wondering the specific reason for the declaration.

Here is the part I am asking about:

.icon::after {
    content: "";
    display: inline;
    width: 150px;
    height: 90px;
    background: url('../img/icon.png') no-repeat;
    background-size: 100%;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
}

Also, quick help with how to show small snippets of code within a question would be helpful. I understand the markdown shown for multiple lines as shown in the "How to ask a question" video, but doesn't function the same here.

Thanks

1 Answer

It may not be immediately apparent in some cases, but remember that display: inline; does not allow you to specify a width or margins, while both display: block; and display: inline-block; do allow it. Width and margins are both typically useful properties when styling icons.

If you want to properly style your code snippets here on the forum, you simply need to include the language for your code snippet immediately following the first set of back ticks. For example, starting your snippets with "````css" will highlight the code snippet as CSS. Hope that helps!