Dan Cederholm proposed the idea of a figure microformat some time ago and I followed up with a post the microformats discuss list. I've continued thinking about it and after throwing down with Tantek over IM, realized that K2's presentational approach of using alignleft, alignright and center classnames on images just didn't hold up over time and, as Tantek asserted, was worse than being semanticly neutral. Therefore, I decided and have been using the following approach to laying out images in my blog posts: .code { border: 1px solid #eee; list-style-type: decimal-leading-zero; padding: 5px; margin: 0; } .code code { display: block; padding: 3px; margin-bottom: 0; } .code li { background: #fff; border: 1px solid #ccc; margin: 0 0 2px 2.2em; }
a img {border:0;}img.figure {max-width:460px;border:2px solid #f7f7f7;}img.figure-a {margin-left:auto;margin-right:auto;display:block;}img.figure-b {float:right;border:0;margin:0 0 6px 6px;}img.figure-c {float:left;border:0;margin:0 6px 6px 0;}
Thus, if you apply the figure class to an image on its own line, it can't be larger than a setting of your choosing (i.e. to not overlap columns, at least in Firefox) and will have a nice border outlining it. Adding figure-a will center it on the line, figure-b will align it to the right and figure-c will align it to the left. I chose these names after consulting with Tantek, reading Dan's piece and thinking about the multiple uses these classes might have beyond images (i.e. for formatting tables or graphs). Figures are often cited in textbooks and newspapers and currently don't conflict with any other microformat. I'd like to see the next versions of Sandbox and K2 support this and deprecate the alignleft, alignright and center image classes in subsequent versions. I'd also like NetNewsWire, Bloglines and other feed readers to support these basic alignment styles. But until then, feel free to use this markup in your own projects and spread the pattern!
💬 Comments from the original post
class="figure a", so that your figure and your a are reusable? and why restrict this stuff to images? surely tables, blockquotes, and lists can be figures as well?relvalue (e.g. wp-att-506).figure-ais semantically different fromfigure-bandfigure-c— there's a legitimate case to be made that a "block" figure (one that interrupts the flow of text) is different from a "floated" figure (one that is floated to the side or placed in a margin) in more ways than just presentation. But how arefigure-bandfigure-csemantically different from one another? Isn't it enough to indicate it's a "floated" figure without specifying which side it's on? There's no point in pretending to be presentaiton-agnostic when the only difference betweenfigure-bandfigure-cis visual. If you think the distinction between left and right floating is important, then you should name the classes accordingly. If not, then renamefigure-atofigure-block, consolidate the other two intofigure-float, and let the implementation decide which side to float them on.img id="figure-506" class="figure f1 left"since the point is that right and left can't confer importance. by the same token, importance can't confer position. -rob's suggestion: i think all this in-post class stuff deserves its own stylesheet, possibly one that should be referenced as an attachment from the post itself, to inform feed readers of the formatting.<?xml-stylesheet href="http://www.somesite.com/css/elements.css" type="text/css" rel="generic" name="common"?>to the top of your atom feed, and getting feedreaders to start picking that up.styleattribute is for! As for the hierarchy you mentioned, Dan, I think you're on to something... after all, we use H1-H6 for headings -- why not doing something similar for images? Anyway, I think I'm going to stick with this for now -- it might not totally take off, but until something better comes along, this is good enough for me.… class="figure primary"That way it's always a 'figure' but can be bumped left or right depending on the next class. This forces adding another class definition to the css file, but it's a nice trade off (arguably more code, but still). Where I'm not so sure is the usage of custom IDs for each 'figure', since that would really depend on the setup of your cms/blogsystem/etc. But from here, using double classes allows you to define the use of the same class on different elements as well, wouldn't it?p.figure {} img.figure {} span.figure {}…and additionally on subelements as per your structure:p.figure img {} p.figure span {} p.figure img.primary {}And so forth… Though, it must be said, i'm not so up to snuff when it comes to semantics, where i'm considered a noob/gentile/unwashed/uninitiated/luser.