css - HTML: center image caption relative to image? -


i'd write html align image caption in centre relative image.

i'd align image , caption together left.

this should true whatever width of containing element.

this have far:

[unknown containing element] <div style="align: left; text-align:center;"> <img src="white.jpg" height="31px" width="200px" /> <span>some caption text</span> </div> [/unknown] 

but it's aligning caption text centre relative containing element.

what need fix?

thanks!

if mean relative image, make caption element wide image, center text. able set width on caption element needs block element, changed :

<div style="align: left; text-align:center;">     <img src="white.jpg" height="31px" width="200px" />     <div class="caption">some caption text</div> </div>  .caption {     width: 200px;     text-align: center; } 

you might set width inline css if easier.

<div style="align: left; text-align:center;">     <img src="white.jpg" height="31px" width="200px" />     <div class="caption" style="width: 200px">some caption text</div> </div>  .caption {     text-align: center; } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -