CSS: Beyond the Retrofit

Molly E. Holzschlag

Molly.com

The Current Best Practice

Point-One Additions

Breaking the Web

Structure and Presentation

CSS To The Rescue!

What’s The Big Deal?

Performance Profiling

Profile: Initial Page

Profile: Whitespace Stripped

Profile: Simplified Structure

Profile: Non-Table Layout

Easing the Bytes

Accessibility Wins

Multimedium Support

CSS is…

CSS principles are…

CSS applications

CSS integrates with documents

Inline style

Inline Style: Example

<ul style="border: 1px dashed black;">
  <li><code>DOCTYPE</code> declarations</li>
  <li>Properly structured <code>head</code> 
    and <code>body</code> elements</li>
  <li><strong>Logical</strong> structures for 
    content markup</li>
</ul>

Embedded style

Linked style

Linked style example

Imported style

Imported style example

The CSS visualized

User and browser style

The cascade

Specificity

Inheritance

Inheritance: simple example

CSS Rule Structure

css rule structure diagram

CSS Properties

CSS Values

CSS properties: Shorthand

CSS property shorthand example

Selectors

Element selectors

Class selectors

Class selector example

ID selectors

ID selectors example

Descendant (contextual) selectors

<p>This sentence is within a paragraph and the <strong> 
information in strong</strong> is styled according to the descendant selector
styles.</p>

Child selectors

Child selector examples

<div id="#content">
  This sentence is a child of the div and therefore the <strong>information 
  in strong</strong> is styled according to the child selector.
  
  <p>This sentence is within a paragraph and the <strong>information 
  in strong</strong> remains unstyled because while a descendant, the 
  strong is within a paragraph, and therefore is not an immediate child.</p>

  </div>

Adjacent sibling selectors

Adjacent sibling selector example

<table>
  <tr>
    <th>Table Header</th>
    <td>Table data - adjacent to the header in the hierarchy</td>
    <td>Table data - second adjacent to the header in the hierarchy</td>
  </tr>
</table>

Pseudo class selectors

Pseudo element selectors

Pseudo element selector examples

p {
  font-family: Arial, sans-serif; 
  font-size: 14px; 
  color: blue;
  }
p:first-line {
  font-weight: bold;
  }

Generated content examples

Commenting and validating CSS

How browsers box

Visualizing the box model

The box generated by an h2 header, which is a block element.

Here’s a paragraph (also block level) with a link to Yahoo!, which is an inline element

The box model

box model

Box model problems

The box test

Misinterpretation of box model

The box test continued

 
This div (including its borders) should be as wide as the blue bar.
 
 
 
 

DOCTYPE switching

About Floats

CSS positioning

Normal flow and containing blocks

Relative positioning

Relative positioning example

Visualizing relative positioning

Absolute positioning

Absolute positioning example

Visualizing absolute positioning

Absolute positioning

Visualizing absolute positioning

Fixed positioning

CSS layouts

Managing browser support

Flipping the switch

Browser Hacking

Hack Ethics 101

Surgical correction

Visualizing surgical correction

Layout Limitations

Resources & More Reading

State Websites using CSS