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 Layout Basics Page Layout with the Float Property Wrapping Text Around Images with Floats

Do display-inline elements get a width and height?

As I understood from Guil's previous video, inline elements (such as span and anchor tags) don't get an adjusted width or height in CSS. They keep their default height and width and flow within the flow, inline.

However, image elements are also inline and get height and width adjustments in CSS. It's obvious why they'd have width/height properties, they're images afterall. But shouldn't images then be block elements?

Why, being inline-elements do images have adjustable heights and widths?

thanks!

Here's a fiddle to help visualize the question https://jsfiddle.net/et7rprqq/1/

1 Answer

Andrew Murphy
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andrew Murphy
Front End Web Development Techdegree Graduate 30,657 Points

Hi Johnny,

Good question. The <img> is what is called a 'replaced' element (more information on that here

Replaced elements will show as inline if you use the browsers inspect tool, but they are treated as inline-block. inline-block keeps it inline, but allows it to take on block element properties like width and height.

I hope this helps a little :-)

thanks so much for shedding light on this, Andrew!