user1027248
user1027248

Reputation: 39

adding caption to image

How do i add a text caption to the image border example mention at http://notions.okuda.ca/2007/02/06/cool-css-image-border-style/

I would like to use the code in the same place that the image path is specified(not in the style sheet), so somewhere in

<img src="SOMETHING.jpg" style="display: block; margin-left: auto; margin-right: auto; padding:8px; border:solid; border-color: #dddddd #aaaaaa #aaaaaa #dddddd; border-width: 1px 2px 2px 1px;" />

Upvotes: 2

Views: 476

Answers (3)

Hawken
Hawken

Reputation: 2119

I don't see how you can do this without making a p tag like so at the very least:

    <p><img src="location/of/my_image" alt=""/><br/>Caption</p>

adding the styling to the p tag instead.

Example: http://jsbin.com/ewazir

Upvotes: 1

Blender
Blender

Reputation: 298156

You do know that a lot has changed since 2007? CSS3 introduced the box-shadow property that does just this, but more realistically.

Without HTML or JavaScript, you can't do the caption, though. CSS can't read properties from HTML.

Here's a demo: http://jsfiddle.net/2DuyU/3/

Upvotes: 1

Bekhbayar
Bekhbayar

Reputation: 456

I think you should write following

<img>your caption</img>

Upvotes: -1

Related Questions