The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Noob question but do I always have to add padding to images in css ?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #299167

    Learning css and working with it for the first time, I read somewhere about padding and margins now this concept is confusing me quite a bit as if I have text near a image surly the padding only needs to be very minuscule or non existent in order to allow for text to flow around it comfortably ?


    I guess for images using padding or margin would end up in the same result. Though reading the documentation on margin and padding I would recommend margin for this. Since padding is the space inside the box and margin is the space outside of the box.
    See some documentation here for example.

    Keep in mind that an image is an inline element by default.


    When you say “allow for text to flow around it comfortably”, it sounds like what you’re wanting is “float” on the image, with a margin around it.

    I’d advise against paddings for images because the padding is “inside” the boundary of the image, making the image appear smaller. The margin is “ouside”, giving space around the image without altering its size. Depending on which way you’re floating you may want margin-left/margin-right and probably margin-top/margin-bottom.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.