• An outline of content • Tags give elements semantic meaning <p>This is a paragraph.</p> • Attributes provide additional information <a href=“http://groupon.com”>Link to groupon.com</a>
for legibility • Whitespace outside of elements will not be rendered • Tags are case insensitive but all lowercase is the norm • Quotes are not necessary around attributes but are the norm • Make sure elements are nested properly <p><em>This is properly nested</em></p> <p><em>This is not properly nested</p></em> • <!-‐-‐ Use comments liberally -‐-‐>
or after an existing one that doesn’t appear in the markup. (content: “?”) • Lots of creative uses - clearfix, carats, layered content, icon fonts, etc. • Should have no semantic meaning or functional use
• Styles in the head of the document take the next highest precedence. <head> <style> p { color: black; } </style> </head> • Styles linked from an external file take the lowest precedence. <head> <link href=“style.css” rel=“stylesheet”> </head>
• Class selectors override element selectors; multiple elements with a class can exist in a document. • ID selectors override element AND class selectors; only one element with an ID can exist in a document. • Adding !important to a declaration overrides everything.
class selectors instead of element selectors whenever possible • Never use IDs to style elements • Limit nesting of selectors as much as possible • Never use !important to override styles
position • Reserved space for element is preserved within the document flow • Can overlap other elements • Set order of overlapping elements using z-index property • If z-index is not set, element positioned last in HTML will appear on top • Often used as container for absolutely positioned elements
with position other than static (default); normally <html> • Removed from normal flow of document; can overlap other elements • Can be used in place of floats, which can be problematic • Must ensure proper space so elements don’t unintentionally overlap
the ability to alter their dimensions to best fill the available space • Good for distributing space evenly within, between or around elements • Supported in most current browsers (<IE 10 not supported) • http://devbryce.com/site/flexbox/
transition: property duration timing-function delay • transition: opacity .3s ease-‐in-‐out .5s; • Pretty good support in current browsers without vendor prefixes • <IE10 fuggedaboutit
space • transform: transform-function • transform: rotate(90deg); • Decent browser support with vendor prefixes • 3D transforms less supported • Often used in conjunction with CSS transitions • Examples: sliding navigation, flip cards, image galleries
certain client criteria are met • width, height, aspect ratio, resolution, media type (screen/print) • @media screen and (max-‐width: 768px) { } • “The first media query is no media query.” - Yoda? • Not supported in IE8 and below
into base, layout, module, state and theme rules • Base - default element styles • Layout - grid and positioning styles • Module - small chunks of reusable styles • State - styles affected by behavior (JavaScript) • Theme - variations on existing styles • http://smacss.com/
(ahem) • Set of base CSS and JS that provide minimally designed components for fast, high-fidelity prototyping • Include responsive grid, form, table, button styles, JS components such as modals and alerts • Can cause sites to look the same (which can be good or bad) • Often include more code than a single project needs
selecting elements • Useful for toggling classes to trigger CSS changes on interactions • Adds some overhead (~32k) but widely used • Lightweight alternatives exist (Zepto ~10k) • jQuery is JavaScript but JavaScript is not jQuery
CSS Tricks (http://css-tricks.com/) • Can I Use (http://caniuse.com/) • A Book Apart (http://www.abookapart.com/) • Developing with Web Standards, John Allsopp (http://idol.pe/OsT9gl)