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
John Coolidge12,614 Points
<img> and <p> in a <section>
I have a multiple section elements in my html that include both an img element and a p element as shown below:
<img src="mask.jpg" alt="Paintball Mask" class="img-mask">
When I style the text in CSS and add a background color or a margin to the class "img-mask", the background color and margin only affect the text of the section element and not the img element.
The CSS is shown below:
I want a background that encompasses both image and text and then I want that section to be positioned relative to other elements on the page. I'm not sure where I'm going wrong here. Any help would be great! Thanks. :)
Here is a photo of the result. With Dev Tools open in Chrome you can see that the margin is applied to the text (the orange area) even though it is applied to the section containing the image and text in the HTML.
Strange..I just tried it in my workspace and it worked correctly for me. Can you post a picture of the result you are getting?