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 trialJohnny Garces
Courses Plus Student 8,551 PointsDo 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
Front End Web Development Techdegree Graduate 30,657 PointsHi 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 :-)
Johnny Garces
Courses Plus Student 8,551 PointsJohnny Garces
Courses Plus Student 8,551 Pointsthanks so much for shedding light on this, Andrew!