Practical Maintainable CSS
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Practical Maintainable CSS

on

  • 15,403 views

Natalie Downe from Clearleft specialises in creating high quality client-side code on agency deadlines. In this talk she shares her development process, from planning through to delivery of a full CSS ...

Natalie Downe from Clearleft specialises in creating high quality client-side code on agency deadlines. In this talk she shares her development process, from planning through to delivery of a full CSS system optimised for maintenance by a client. The talk includes CSS rules of thumb developed over seven years in the field, as well as tips for taming the beast that is Internet Explorer.

Statistics

Views

Total Views
15,403
Views on SlideShare
11,440
Embed Views
3,963

Actions

Likes
43
Downloads
235
Comments
1

14 Embeds 3,963

http://natbat.net 3681
http://blog.natbat.net 155
http://lanyrd.com 90
http://www.slideshare.net 11
http://webcache.googleusercontent.com 7
http://translate.googleusercontent.com 5
http://www.linkedin.com 5
http://static.slideshare.net 2
http://web.archive.org 2
https://www.linkedin.com 1
http://htmledit.squarefree.com 1
https://lanyrd.com 1
http://www.ianlewis.org 1
http://www.slideee.com 1
More...

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Thanks Natalie, I'll refer people to this constant, er, consistent, er .. all the time! :-)

    The 40 min Vimeo recording has a nice tempo and the Silverback screencap works really well. Thanks!
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • Hello! <br /> <br /> I’m a front end engineer, and I work for Clearleft! <br /> <br /> We do information architecture, user experience design, and usability testing <br /> <br /> and as part of all of this, we often provide our clients with the HTML and CSS that implements our designs, and that’s what I focus on. <br /> <br /> At Clearleft, we strive to produce ... <br />
  • ... high quality client-side code, <br /> <br /> which for us means ... <br />
  • ... beautiful and valid markup, <br /> <br /> we delight in finding the perfect element for every context <br /> <br /> we are perfectionists ... <br /> <br /> <br /> http://www.flickr.com/photos/21984953@N00/38992864/ <br />
  • ... we use meaningful markup and class names, <br /> <br /> and avoid polluting our code with too many divs or spans <br /> <br /> this keeps things lean, mean and fast loading ... <br /> <br /> http://www.flickr.com/photos/24839392@N00/2396027766/ <br />
  • ... Unlike this apple here, we ensure that our sites are “bulletproof” <br /> <br /> This means that the design holds together despite varying content, for example user generated content or anything that is being spat out from a content management system <br /> <br /> Our sites also work when the browser is resized or the user changes their font size ... <br /> <br /> http://www.flickr.com/photos/nebarnix/337062435/ <br /> <br />
  • ... we embrace the trifle of the web, <br /> <br /> Now I don’t actually like trifle very much, but it does make a nice analogy for client-side web development <br /> <br /> we separate our content and behaviour from presentation, <br /> <br /> this means our sites are still accessible even when CSS or JavaScript is disabled ... <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> (for a detailed and beautiful description of the ‘trifle of the web’, please see page 6 of Cal Henderson’s “Building Scaleable websites”) <br /> <br /> btw yes I know this is not a photo of a proper trifle. <br /> <br /> http://www.flickr.com/photos/83096974@N00/466881574/ <br />
  • ... we then have to hand over our markup and CSS <br /> <br /> to external developers to integrate with their back-end code <br /> <br /> and for the client to maintain in the long term. <br /> <br /> <br /> and we have to do all of this ... <br /> <br /> <br />
  • ... on agency deadlines, <br /> <br /> this normally works out at about 2 or 3 weeks to build the client-side code for a brand new site ... <br />
  • ... Every presentation needs some boxes and arrows. But don’t be mislead by the diagram, I’m not just a cog in a machine. <br /> <br /> I get to spend all day making things! ... <br />
  • ... I take designs from our very talented design team and turn them into front-end codeTo give you an example of the range of designs I’ve been implementing recently, here are a few screenshots of ones that are not currently under NDA ... <br />
  • ... RateMyArea was the first site I helped with at Clearleft, nearly a year and a half ago now ... <br />
  • ... UX London is a conference we're running in June. This is the first site we've implemented using ideas and a doctype from HTML 5 ... <br />
  • ... as a web design agency, naturally the hardest site to build was our own. This took at least a year of arguments, many many designs and about five iterations of the front-end code! ... <br />
  • ... Tourdust was the first site we built using an agile methodology with an external server-side development team. This made maintainability and implementation flexibility even more important than usual ... <br />
  • ... and this is what I should have been working on when I was writing this talk! <br /> <br /> As a lover of cute pictures of tigers, it’s great to have some content I can get my TEETH in to! ... <br /> <br /> <br /> <br /> <br /> Ho Ho! <br />
  • So what do I need to get started? Well, obviously I need the design... <br />
  • ... Our designers mostly work in Fireworks, so generally I get handed a Fireworks file with the different pages as layer groups. But the design alone isn't enough <br />
  • ... I also need to have some conversations, both with the designer and any server side developers, before I can start planning how I’m going to build the site. ... <br /> <br /> <br />
  • ... we’ll talk about liquid, elastic and fixed a bit later on. <br /> <br /> What’s the minimum content scenario? By that, I mean what happens when things aren’t there - for example, a news story that normally has an image but sometimes has to display neatly without one, or a listing page that sometimes has no items <br /> <br /> Will there be themed sections? For example, do news pages have a different header or colour scheme than product listings <br /> <br /> How should we deal with text wrapping e.g. in the navigation? This is especially important for tabs and horizontal navigation. Text wrapping around images is another common query. <br /> <br /> Depending on the nature of the design and the budget, we might opt to use progressive enrichment for some design elements. This means that standards compliant browsers are rewarded with little bits of visual flair which shouldn't be missed by unfortunate ludites stuck with IE ... <br />
  • ... conversations I'll need to have with the developer include if a CMS will be used to manage content. In my experience projects with a CMS involve giving up full control over the resulting markup. <br /> <br /> If internationalisation is a requirement, it’s best to avoid using images with text in them as they make translation much harder. Languages such as German can have translations that are much longer than the original English, as such things are more likely to wrap. <br /> <br /> Languages such as Arabic are particularly trick to support, as they require both the text and the design to flow from right to left instead of from left to right. The browser support for this can be a little shaky, so supporting these languages will add quite a bit of time to the estimate. <br /> <br /> How the themes are to be managed is something else to think about, will I be controlling this with a class on the body or does the CSS need to be generated <br /> <br /> All these conversations lead into the doctype decision. I'm not going to enter this minefield of a debate right now (other than to say that given the choice I prefer HTML 4 strict), feel free to grab me about this later ... <br />
  • ... as I mentioned earlier, this is a decision that has to be made right at the start. <br /> <br /> Not everyone browses the web at the default font size, or with a standard sized browser window. Why not make your site look like it was designed with them in mind? <br /> <br /> In CSS it’s possible to define dimensions in terms of a percentage of the overall browser window, or alternatively as a multiple of the size of the font. Either of these techniques can be used to create what’s known as a flexible layout. <br /> <br /> I feel that flexible layouts are a way of breathing life in to a static design, and adapting it to the flexible nature of the web <br /> <br /> Regardless of the decision you make here, it’s important to resize your browser window and increase and decrease your font size during development to see how this affects the page... <br />
  • ... in a liquid design, the layout adjusts based on the browser width. This is achieved by specifying dimensions in percentages ... <br />
  • <br />
  • ... an elastic layout changes as the font size is increased or decreased. This can be done by setting dimensions using ems, a measurement which is tied to the font size. <br /> <br /> The key advantage of elastic is that the number of words on a line stays roughly the same, allowing for the optimum readability length of 75-100 characters per line to remain <br /> <br /> ... I'd you a video for fixed, but you would’t be able to tell it from a screenshot! ... <br />
  • <br />
  • Be afraid of setting heights on anything, especially when it contains text. Text is liable to spill out or overlap other elements on the page if the font size is increased or more text is added. <br /> <br /> Vertigo is healthy on the web ... <br /> <br />
  • ... If you want to know more about implementing flexible layouts, I can recommend this book which came out just a couple of months ago ... <br />
  • Just as you wouldn't consider making a house without a proper plan, I like to spend some quality time with pen and paper before writing a single line of code ... <br /> <br /> <br /> http://www.flickr.com/photos/23762528@N04/3000454012/ <br />
  • By the end of the planning stage I want to feel comfortable with how I am going to tackle the build <br />
  • ... If I come across something in the design that doesn't have an obvious best solution, I like to create a separate HTML prototype. <br /> <br /> This is my way of proving that something is possible to build in a robust manner. <br /> <br /> Quite often I will roll these prototypes in to the final build. <br /> <br /> Sometimes if I tell Paul, our designer that something is not possible he'll prototype it himself to prove otherwise ... <br />
  • ... now, looking at the site as a whole, we need to identify the <br /> <br /> page structure, <br /> <br /> as well as common components.... <br />
  • ... for example, identify areas, such as the ... <br />
  • ... header ... <br />
  • ... primary content ... <br />
  • ... secondary content ... <br />
  • ... individual content components such as the teaser on this page <br /> <br /> we'll talk about common components in more detail later, as they are key to creating reusable code ... <br />
  • ... A lot of modern web design is based around a grid. <br /> <br /> it ensures elements are aligned with each other, and gives the site a nice consistent visual feel <br /> <br /> this needs ... <br /> <br /> http://www.subtraction.com/2004/12/31/grid-computi <br />
  • ... this needs diagrams ... <br /> <br /> http://flickr.com/photos/adactio/1799116343/ <br />
  • ... lots of diagrams, <br /> <br /> it basically boils down to proportions, analyse the site as a whole, <br /> <br /> look at content areas and see how they interact with each other and align to the basic grid <br /> <br /> <br /> ... <br />
  • ... the grid will normally have some dependancy on the base font size, ask your pet designer if you are not sure. <br /> <br /> you will need to make some initial calculations before you come up with the precise proportions <br /> <br /> I’m pretty hopeless at maths so for me this also involves yet more diagrams <br /> <br /> Don’t be too exact though, IE isn’t very good at counting, and will fall victim to rounding errors <br /> <br /> ... <br />
  • ... If you figure out your heading levels from the start this will help decisions later on. <br /> <br /> This seems like a subtle point, but properly designed heading levels are an excellent start for coming up with a sensible overall structure for your site ... <br /> <br />
  • ... to avoid making more work for yourself, it’s best to identify the typographical hierarchy for the overall site as early as possible ... <br />
  • Next I'm going to share with you some of my favourite tools of the trade ... <br /> <br /> http://www.flickr.com/photos/7881731@N06/2639919440/ <br />
  • ... some sort of version control is invaluable, especially when working with a team. <br /> <br /> We use Subversion, with the long awaited and beautiful Mac application Versions. <br /> <br /> Most of our designs are now done in Fireworks, so I have a copy for slicing up images and otherwise interpreting the design. <br /> <br /> TextMate is my editor of choice, and I also use ColourSchemerStudio and CSSEdit ... <br />
  • ... I use ColorSchemer Studio to pick colours off the design - this means I can store colours from the design for future reference, especially useful for theming ... <br />
  • ... CSSEdit is a development tool for the mac, which I absolutely love. It only edits CSS, but it does it so well that I don’t mind having an extra tool. <br /> <br /> Grouping is by far my favourite feature. <br /> <br /> you can see here on the left hand side it has displayed my nested groups which I use as a navigation aid to traverse the CSS on the right <br /> <br /> There are Windows alternatives available; anything with code folding is worth a look ... <br /> <br /> http://macrabbit.com/cssedit <br />
  • ... Firefox is my main development browser, mainly because of the extensions. Firebug is absolutely invaluable - if you ever have to touch front-end code and you don’t have this installed, look it up. <br /> <br /> The HTML Validator extension is incredibly hard to track down, since they don’t update the version on the Firefox addons site. It adds a green “tick” at the bottom right of the browser, and is a constant illustration of whether my code is valid. <br /> <br /> Operator is how I test my microformats. <br /> <br /> YSlow is an extension for an extension! It adds a new pane to Firebug highlighting potential performance problems in the front end code. <br /> <br /> <br />
  • ... topographic view in the Web developer toolbar is useful for exposing the bare bones of your site. Let’s turn it on ... <br /> <br /> <br />
  • ... here for example you can immediately see that the container on the lower half of the page is not clearing around its two internal floated elements ... <br />
  • We follow our own version of Yahoo!’s graded browser support guidelines, which define which browsers should be tested for the full experience, which browsers should at least make the content accessible and which can be safely ignored. You’ll be glad to hear that we don’t code for Netscape 4 any more! <br /> <br /> I use VMWare Fusion to run different versions of Windows on my Mac, which lets me safely run more than one version of IE at a time. <br /> <br /> As a general rule, I test constantly throughout development in Firefox, Opera, Safari and IE 6 and 7. I double check other browsers such as Camino and Safari on Windows towards teh end of the development cycle. <br />
  • ... I’ve been working with CSS for a long time, and I’ve attempted to distil some of that knowledge in to some heuristics, or rules of thumb. Ten would be a nicer number since we all have ten fingers, but I have eight - so maybe these should be ... <br /> <br /> <br /> http://www.flickr.com/photos/95141439@N00/357358126/ <br />
  • ... 8 CSS rules of ... <br />
  • ... finger instead ... <br />
  • ... if you only take away one rule, make sure it’s this one. It’s key to developing the correct mindset. <br /> <br /> If you think about pages first, you’ll find yourself duplicating large amounts of CSS code. Every time you need to create a new page you’ll have to start mostly from scratch. <br /> <br /> Instead, think about the reusable components that make up the design. Create a core set of components that can mixed together to create hundreds of different page combinations ... <br /> <br /> <br /> <br />
  • ... look for opportunities to classify similar content elements together ... <br />
  • ... which leads us nicely to rule 3: prefer CSS class selectors to IDs. <br /> <br /> Rules assigned to a class (or type of thing) are reusable. By definition, ID blocks can only apply to a single element on a page. <br /> <br /> Classes are the only way to build reusable components. <br />
  • ... another advantage of classes is that you can apply more than one class to an element. Just as permutations of components can create many different types of page, permutations of classes that have been designed to be composable can create many different types of component <br /> <br /> for example, one class could define the layout properties of an element while another class applies its theme and colour scheme. This allows for more possible combinations without needing to add more code ... <br />
  • ... you don’t need to get carried away and classes to everything though ... <br />
  • ... so here we have a news item, and the h2 has a class of news-heading. <br /> <br /> Say we wanted to set a colour on the heading. Weasel isn't actually a colour in the spec, but Simon insists it should be... <br /> <br /> <br />
  • ... A more efficient way of achieving the same effect is to take advantage of the context of this h2 ... <br />
  • If your selectors are too long, you are tightly coupling your CSS to your markup <br /> <br /> You can't move things around, because the selector binds the rules to an exact point in the markup hierarchy. <br /> <br /> This reduces its reusability. <br /> <br /> Shorter selectors are also easier to over-ride. <br />
  • If you’re keeping your selectors short, it's more important to understand the cascade, in particular the way CSS rules over-ride earlier rules with the same specificity. <br /> <br /> Following a sensible convention also makes it easier to find things and understand how the code works... <br />
  • ... if you’re doing a flexible layout it’s a lot easier to deal with changing designs if the internal dimensions are set in percentages. Changing the outer container’s width will cause everything inside it to re-adjust... <br />
  • ... here's a planning artifact that illustrates internal widths set in percentages. <br /> <br /> It's an elastic site, so the overall width is set in ems. <br /> <br /> Also, I've added a max-width of 100% to make sure that you never end up with a horizontal scrollbar (or crawlbar) even if the user makes their text huge. This is a handy trick for making elastic designs more robust. ... <br />
  • <br />
  • ... for things like font ... <br />
  • ... margins or background. <br /> <br /> I don't. necessarily. <br /> <br /> Longhand can often be preferable, particularly with background. <br /> <br /> firstly it makes debugging in firebug easier, you can see where overrides are effective. <br /> <br /> you will also have similar issues as the ‘one ruleblock per line’ when it comes to source control. you can tell that a line has changed but its not imediately obvious which part of that line. <br /> <br /> but mainly and this is more noticable with backgrounds ... <br />
  • ... that by using shorthand its easy to override declarations without meaning to. <br /> <br /> For Example if you are using all the sections of the background like we are here, then its easy to see what this is doing, <br /> <br /> but if on an element you have already specified it as ... <br />
  • ... having a delightful lime green background, and you then you want to have a variation of that inherit the lime styles but also have a transparent background image ... <br />
  • ... rofl.gif <br /> <br /> if you specify it using just the background declaration, then this overwrites the lovely lime green colour <br /> <br /> one solution of course is to specify the colour here too, but then ‘lime’ is in two places, you are not taking advantage of inheritance within declarations, <br /> <br /> and what if you suddenly want to change to pink, now you have to change it in two places, this is not optimal <br /> <br /> also always bear in mind that people editing your code are likely to be copy and pasting from the rest of the file, <br /> <br /> so you have to set a good example with this throughout your code. <br /> <br /> so a better solution would be ... <br /> <br /> <br />
  • ... use the longhand version, and override with subsequent longhand versions ... <br /> <br /> <br />
  • So these are my rules of thumb. I'll be making the list of rules available later on natbat.net. <br />
  • a.k.a. dealing with the inevitable decent in to browser bug hell <br /> <br /> http://www.flickr.com/photos/jurvetson/17945646/ <br />
  • <br />
  • I’m giving away the answer to a good interview question here. <br /> <br /> <br /> Could it be a hasLayout bug? <br />
  • As Noel Edmonds will apparently tell you in his best selling self help guide, a Positive Mental Attitude is essential in dealing with IE. <br />
  • ... the alternative is to sell your soul to unspeakable demons from alternative dimensions. They don’t like IE very much either. ... <br /> <br /> http://images.google.com/imgres?imgurl=http://www.thecimmerian.com/wp-content/uploads//2009/02/cthulhu-6.jpg&imgrefurl=http://www.thecimmerian.com/%3Fcat%3D30&usg=__1_3xzSSQ0vRKSiae37BhSy2KKeE=&h=405&w=540&sz=45&hl=en&start=1&um=1&tbnid=vBgWGVpq9eIEiM:&tbnh=99&tbnw=132&prev=/images%3Fq%3Dcthulhu%26um%3D1%26hl%3Den%26client%3Dsafari%26rls%3Den-us%26sa%3DN <br /> <br />
  • ... don’t worry, they’re not as scary as they first seem! In case you’re wondering, that’s me dressed as a pumpkin. <br /> <br /> code reviews should be an essential part of your development process. If you can explain your CSS to someone else and have them understand it, <br /> <br /> there’s a pretty good chance what you have done is robust and maintainable. ... <br />

Practical Maintainable CSS Presentation Transcript

  • 1. Practical, maintainable CSS Natalie Downe, 4th March 2009 Thursday, March 5, 2009
  • 2. Hello! Thursday, March 5, 2009
  • 3. High quality code Thursday, March 5, 2009
  • 4. beautiful and valid markup Thursday, March 5, 2009
  • 5. semantic markup & class/id names Thursday, March 5, 2009
  • 6. bulletproof Thursday, March 5, 2009
  • 7. separate content, presentation & behaviour Thursday, March 5, 2009
  • 8. for handover Thursday, March 5, 2009
  • 9. on agency deadlines Thursday, March 5, 2009
  • 10. Me Input Output I sit in the middle Thursday, March 5, 2009
  • 11. Designs, Pattern Information Me portfolio architecture & & CSS system conversations I sit in the middle Thursday, March 5, 2009
  • 12. RateMyArea Thursday, March 5, 2009
  • 13. UX London Thursday, March 5, 2009
  • 14. Clearleft Thursday, March 5, 2009
  • 15. Tourdust Thursday, March 5, 2009
  • 16. WWF Thursday, March 5, 2009
  • 17. Designs, Information Me architecture Output & conversations Input Thursday, March 5, 2009
  • 18. The design Thursday, March 5, 2009
  • 19. Server-side Designer developers Me Conversations Thursday, March 5, 2009
  • 20. ... with the designer Liquid, elastic or fixed? What’s the minimum content scenario? Missing abstracts, images etc. Will there be themed sections? How should we deal with text wrapping e.g. in navigation? Is there room for progressive enrichment on complex issues? Thursday, March 5, 2009
  • 21. ... with the developers Will a CMS be involved? How much control do I have over the markup? Internationalisation - Arabic etc? RTL? How will themes be implemented? Doctype? Thursday, March 5, 2009
  • 22. Liquid/Elastic/Fixed? Thursday, March 5, 2009
  • 23. Liquid Thursday, March 5, 2009
  • 24. Liquid Thursday, March 5, 2009
  • 25. Elastic Thursday, March 5, 2009
  • 26. Elastic Thursday, March 5, 2009
  • 27. Vertigo is healthy on the web Thursday, March 5, 2009
  • 28. Thursday, March 5, 2009
  • 29. Planning Thursday, March 5, 2009
  • 30. Aim: a mental map of how the core markup will fit together Thursday, March 5, 2009
  • 31. Prototyping I prototype the missing pieces of the puzzle - the bits I don’t understand yet I’ll browser test these fully If they work, I’ll probably roll them in to the build (and hence save time later) Means I’m more confident estimating time, and talking to the server-side developers Paul sometimes prototypes to prove me wrong! Thursday, March 5, 2009
  • 32. Page structure and common components Thursday, March 5, 2009
  • 33. Thursday, March 5, 2009
  • 34. header Thursday, March 5, 2009
  • 35. primary content Thursday, March 5, 2009
  • 36. secondary content Thursday, March 5, 2009
  • 37. teaser Thursday, March 5, 2009
  • 38. The grid Thursday, March 5, 2009
  • 39. Diagrams Thursday, March 5, 2009
  • 40. Lots of diagrams Thursday, March 5, 2009
  • 41. Font size calculations Thursday, March 5, 2009
  • 42. Heading levels Thursday, March 5, 2009
  • 43. Identify common sizes for each heading level Override these on a case by case basis If you don’t plan this at the start you’ll have to redefine them far too often, and you make more work for yourself Thursday, March 5, 2009
  • 44. Environment Thursday, March 5, 2009
  • 45. Tools of the trade Subversion with Versions.app Fireworks TextMate ColorSchemer Studio CSSEdit Thursday, March 5, 2009
  • 46. ColorSchemer Studio Thursday, March 5, 2009
  • 47. CSSEdit Thursday, March 5, 2009
  • 48. Firefox + extensions Firebug HTML Validator - http://icanhaz.com/firefox-validator Operator (for Microformats) YSlow Web development toolbar (for topographic view) Thursday, March 5, 2009
  • 49. Topographic view Thursday, March 5, 2009
  • 50. Topographic view Thursday, March 5, 2009
  • 51. Testing environments Yahoo! Graded Browser Support VMWare Fusion Constantly test in: Firefox Opera Safari Internet Explorer 6 and 7 Thursday, March 5, 2009
  • 52. 8 CSS rules of thumb Thursday, March 5, 2009
  • 53. 8 CSS rules of thumb Thursday, March 5, 2009
  • 54. 8 CSS rules of finger Thursday, March 5, 2009
  • 55. 1. Think in terms of components, not pages Thursday, March 5, 2009
  • 56. 2. Think about types of thing, not individual things Thursday, March 5, 2009
  • 57. 3. Prefer classes to IDs Thursday, March 5, 2009
  • 58. 4. Create composable classes Thursday, March 5, 2009
  • 59. 5. Use descendent selectors to avoid redundant classes Thursday, March 5, 2009
  • 60. <div class=quot;newsquot;> <h2 class=quot;news-headingquot;>Weasel wins tug of war</h2> <p>A weasel defeated an aardvark...</p> </div> h2.news-heading { color: weasel; } Thursday, March 5, 2009
  • 61. <div class=quot;newsquot;> <h2>Weasel wins tug of war</h2> <p>A weasel defeated an aardvark...</p> </div> .news h2 { color: weasel; } Thursday, March 5, 2009
  • 62. 6. Keep your selectors as short as possible Thursday, March 5, 2009
  • 63. 7. Order your CSS rules loosely by specificity Thursday, March 5, 2009
  • 64. 8. Prefer percentages for internal layout dimensions Thursday, March 5, 2009
  • 65. Thursday, March 5, 2009
  • 66. Rules of thumb 1. Think in terms of 6. Keep your selectors as short components, not pages as possible 2. Think about types of thing, 7. Order your CSS rules loosely not individual things by specificity 3. Prefer classes to IDs 8. Prefer percentages for internal layout dimensions 4. Create composable classes 5. Use descendent selectors to avoid redundant classes Thursday, March 5, 2009
  • 67. Quality Assurance Thursday, March 5, 2009
  • 68. Internet Explorer Avoid the inevitable IE sinking feeling: test constantly throughout development Use conditional comments to include a separate IE stylesheet Avoid hacks Don’t re-engineer everything just for IE - completely forking your solutions is a really bad idea Thursday, March 5, 2009
  • 69. Internet Explorer Do I recognise it? Double margin float bug, I’m looking at you Validate markup and CSS Apply borders to innermost elements (compare with Firefox - topographical view is useful) hasLayout bug? Apply position:relative starting at the innermost element Search Google / css-discuss Reduce to the simplest possible non-working version Thursday, March 5, 2009
  • 70. Stay strong... Thursday, March 5, 2009
  • 71. Or pray to the elder gods Thursday, March 5, 2009
  • 72. Grr... frickin’ IE! Or pray to the elder gods Thursday, March 5, 2009
  • 73. Code reviews Thursday, March 5, 2009
  • 74. Designs, Pattern Information Me portfolio architecture & & CSS system conversations Output Thursday, March 5, 2009
  • 75. Pattern portfolio Smallest possible number of documents Expresses every component and layout structure Documents how the markup and CSS should be used Illustrates the project’s shared vocabulary Links to current stylesheets A powerful regression testing tool Thursday, March 5, 2009
  • 76. Example Thursday, March 5, 2009
  • 77. A CSS system Thursday, March 5, 2009
  • 78. a CSS system ... involves a top down approach is personalised for an individual site incorporates a pattern portfolio of reusable markup patterns and CSS defines a shared vocabulary for developers Thursday, March 5, 2009
  • 79. ? nat@natbat.net Thursday, March 5, 2009