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!

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


Image padding in html?

So, I tried to do padding with html by <hspace> for my CMS posting, but just found out that html5 does not support it anymore.

Is there any way I can do within html to add padding on image? I know I can do it with CSS easily, but I'm not familiar with CMS, so I guess I have to do it in inline.

Any suggestion please?

3 Answers

Kevin Kenger
Kevin Kenger
32,834 Points

Hey Aoi,

You could add an inline style to your HTML tag using CSS, which wouldn't require an external style sheet.

<img src="whatever.jpg" alt="whatever" style="padding: 10px;">
Freek Wevers
Freek Wevers
Courses Plus Student 14,599 Points

Although Kevin's answer is correct, I still recommend using a style sheet. It's just good practice to keep your semantics (HTML) separated from your layout (CSS). If you put all your styles inline then it's going to give you a headache when you need to make some style changes later on. I'd suggest to spend some time to get to know your CMS and figure out how to add the style sheet I think you need. It's going to save you time in the long run...

Kevin, Thanks a lot, this totally worked!

Freek, Yea, that's what I am thinking also,,, I guess I gotta familiarize myself with this CMS (Drupal). It is just too complicated to figure out to me haha