<div>Yesterday in another thread i mentioned that the sample CSS at <a href="http://codex.wordpress.org/CSS#WordPress_Generated_Classes">http://codex.wordpress.org/CSS#WordPress_Generated_Classes</a> was ineffecient and redundant. Emil challenged me to produce something better so I wanted to run it past this group before I submitted it. After all you guys are the ones that would be seeing it on submitted themes.</div>
<div><br></div><div>My goal in writing this CSS was to make it accessable to newer developers, remove repetitive rules, and reduce selector complexity. Visually the new CSS appears the same as the old CSS (one exception-explained below), but it's half the size and should be easier to manage.</div>
<div><br></div><div>Thanks for reading this, sorry it's so long.</div><div><br></div><div><br></div><div>My tests are here, CSS is in the header to make it easier to view. HTML is identical.</div><div><br></div><div>
Original ... <a href="http://wp-themedev.ludwigdevelopment.com/wp-content/uploads/2012/07/new.html">http://wp-themedev.ludwigdevelopment.com/wp-content/uploads/2012/07/new.html</a></div><div>New ... <a href="http://wp-themedev.ludwigdevelopment.com/wp-content/uploads/2012/07/original.html">http://wp-themedev.ludwigdevelopment.com/wp-content/uploads/2012/07/original.html</a></div>
<div><br></div><div><br></div><div>Here is a breakdown what I changed and why.</div><div><br></div><div>.alignnone - added display: inline-block so that when .alignnone is applied to either a div or an image it will display the same. This is kind of a judgement call on my part but I feel that image layout should be consistant whether or not there is a caption.</div>
<div><br></div><div>div.aligncenter - removed as unnecessary because the first selector will already catch any divs with .aligncenter.</div><div><br></div><div>a.img.alignright, a img.alignnone, a img.alignleft, a img.aligncenter - removed, duplicates of the base alignment class with more complicated selector.</div>
<div><br></div><div>.wp-caption.alignnone, .wp-caption.alignleft, .wp-caption.alignright - removed, duplicates of the base alignment class with more complicated selector.</div><div><br></div><div>.wp-caption p.wp-caption-text - Changed selector to just .wp-caption-text. No need to complicate it. It really shouldn't show up outside of a .wp-caption and if it does someone had to of put it there on purpose and they can deal with it.</div>
<div><br></div><div><br></div><div>Final CSS</div><div><br></div><div>/* =WordPress Core</div><div>-------------------------------------------------------------- */</div><div>.alignnone {</div><div> display: inline-block;</div>
<div> margin: 5px 20px 20px 0;</div><div>}</div><div><br></div><div>.alignright {</div><div> float:right;</div><div> margin: 5px 0 20px 20px;</div><div>}</div><div><br></div><div>.alignleft {</div><div> float: left;</div>
<div> margin: 5px 20px 20px 0;</div><div>}</div><div><br></div><div>.aligncenter {</div><div> display: block;</div><div> margin: 5px auto;</div><div>}</div><div><br></div><div>.wp-caption {</div><div> background: #fff;</div>
<div> border: 1px solid #f0f0f0;</div><div> max-width: 96%; /* Image does not overflow the content area */</div><div> padding: 5px 3px 10px;</div><div> text-align: center;</div><div>}</div><div><br></div><div>
.wp-caption img {</div><div> border: 0 none;</div><div> height: auto;</div><div> margin: 0;</div><div> max-width: 98.5%;</div><div> padding: 0;</div><div> width: auto;</div><div>}</div><div><br></div><div>
.wp-caption-text {</div><div> font-size: 11px;</div><div> line-height: 17px;</div><div> margin: 0;</div><div> padding: 0 4px 5px;</div><div>}</div><div><br></div>