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 trialArikaturika Tumojenko
8,897 PointsWidth doesn't apply, left margin does. Why?
Although width, just like margin-left applies horizontally (at least in theory), when it comes to inline elements width has no effect but left-margin does. What's the explanation?
2 Answers
Ryan M
16,509 PointsTo add a width to an inline element you need to change its display value to inline-block
.yourlnlineElement {
display: inline-block;
width: 200px;
}
ywang04
6,762 PointsIt's important to know that, when it comes to margins and padding, browsers treat inline elements differently. When an element's display is set to in-line like the items here in the header. The browser will not apply any height and width properties. Or top and bottom margin settings. An inline element will only accept left and right margins and any padding value.
This has been mentioned in this video.
Laly Singh
2,029 Points*An inline element will only accept left and right margins and "left and right" padding value