Skip to content

Styling photo captions with CSS | Devlounge

Link To Full Story: www.devlounge.net

Sure, some photos are self-explanatory, but most photos are best served with text captions. It’s true for traditional media like newspapers and magazines, and just as true for blog posts and web articles. Here’s a quick tip on using photo captions and styling them nicely with the magic of CSS:

Now I won’t delve too deeply into how to code your captions. Some people do it this way:

<p><img src=”image.jpg” alt=”image” /><br />Caption text here</p>

But apparently the proper, semantic way would be to use a definition list, like so:

<dl>
<dt><img src=”image.jpg” alt=”image” /></dt>
<dd>Caption text here</dd>
</dl>

where:
dl = definition list
dt = definition term
dd = definition definition

Got that? Okay, let’s prettify it with some CSS. I want to caption a photo of a nicely sharpened pencil.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*