views:

133

answers:

2

Hey guys,

I have a web page where I have text with images. I write some text (in a paragraph) then put an image, then another paragraph.

Should I put p tags around the image too, or should I just leave it in between with just the img tag?

The reason I ask this is because up until now I was just plopping images in between paragraphs, but now if I want to add more than one image or add an image and an anchor then the don't sit together right. The other thing I tried was adding

<p></p>

in between two images but I feel like that is wrong :P

+3  A: 

You could use CSS to make the images act as blocks rather than as inline-blocks:

Put the following in your CSS somewhere:

img { display: block; }

Or if you have some images that you want to display inline, then add class="block" to your img tags, and change the css to this:

img.block { display: block; }
pib
Good idea. It's always best to get away with as few html elements as possible. If you want an `img` to act as a block level element, just give it `display:block`.
Skilldrick
A: 

I can't think of any reason why you wouldn't use <p><img/></p> if that's how you want it laid out. that way the mark up clearly describes the layout.

it is certainly more legible than changing the display type for all images. the best alternative would be to create a css class img.block {display:block;} + <img class="block"/>

pstanton