13.02.2013 Views

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

40<br />

So, let’s say that for most modules in the sidebar, I want to style any tags assigned class="fullsize" to float to the<br />

right within the module, with a 5-pixel margin on the left and bottom and no border. With the new hooks, the generic style<br />

should now look like this:<br />

#sidebar .module img.fullsize {<br />

float:right;<br />

margin:0 0 5px 5px;<br />

border:none;<br />

}<br />

This selector uses the class I’ve assigned to my wrapper , along with #sidebar, so that if I decide to use the module class<br />

anywhere else in the layout, this rule will not apply.<br />

With that taken care of, I can now style the video module to float the image to the left instead of to the right, and adjust the<br />

margins accordingly:<br />

#sidebar #mod-media img.fullsize {<br />

float:left;<br />

margin:0 5px 5px 0;<br />

}<br />

By replacing the class (.module) with the ID (#mod-media) in the selector, I instruct the browser to apply the generic styles<br />

first, and then override the float and margin settings.<br />

IDs have higher specificity than classes. See http://molly.com/2005/10/06/css2-and-css21-specificityclarified/<br />

for a thorough explanation of how specificity is calculated, and see http://stuffandnonsense.<br />

co.uk/archives/css_specificity_wars.html for a more lighthearted overview.<br />

This same approach will get you out of almost any hole dug for you by CMS-generated markup. While none of us really want<br />

to use an ugly selector like body#events #content .item .module .summary #membership p.permalink span {}, if you’re<br />

in a bind and need to get the job done, combining and layering selectors along with a wrapper or two will make your<br />

life much less stressful.<br />

The typography<br />

I’m a typography nut, and type usually features prominently in my designs. HTML text is at best difficult to control. Even with<br />

CSS, font choices are limited to those installed on a user’s operating system, and typographical control really isn’t possible.<br />

Yet my design uses headings set in the band’s typeface of choice, Franklin Gothic Condensed. I don’t want to hinder the basic<br />

accessibility of the site. I’m not shooting for perfection in that area, but at the same time, it would be irresponsible to shut<br />

people out entirely by using bad markup. But somehow I need to get that type to display. Enter CSS image replacement for<br />

fixed headings, and sIFR for text that needs to change regularly, such as article headings generated by the CMS.<br />

Let’s start with the vertical text headings. They are the most obvious candidate for special treatment, as there isn’t any way<br />

to mimic them using HTML text alone.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!