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

HTML How to Make a Website Adding Pages to a Website Make an About Page

how do you set an image to be block element

please help.

3 Answers

Hi Callen!

Images should be block level elements by default, however, if you want to make sure they are block level you can do something like this:

img {
display: block;
}

I hope this helps!

Hi Mark,

Images are inline by default.

You're correct, Jason. It should be inline. My mistake.

First thing is why do you want to be your images be "block", maybe it's better to make a div or unorderd list where the image is in "block" ?

What Mark says is fine, but is for all your images,

<div class="imageholder">
      <img src="path/to/image/" alt="description" title="other description">
</div>

and then in your css

.imageholder{
    display:block;
}

I do agree with Robert as well that u could have either a wrap or container around your image. U could also asign a specific class to specific images u want to be displayed as block elements.

All of it depends from complexity of the project you are working on really, if its a small one pager, i would go with specific classes as it probably would save me code on my index file.

Its all up to you man which technique do u prefer.