WRITE BETTER HTML BY WRITING BETTER CSS

Similar documents
JJY s Joomla 1.5 Template Design Tutorial:

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

Style & Layout in the web: CSS and Bootstrap

Responsive Web Design: Media Types/Media Queries/Fluid Images

Web Design for Programmers. Brian Hogan NAPCS Slides and content 2008 Brian P. Hogan Do not reproduce in any form without permission

How To Create A Web Page On A Windows (For Free) With A Notepad) On A Macintosh (For A Freebie) Or Macintosh Web Browser (For Cheap) On Your Computer Or Macbook (

Responsive Web Design for Teachers. Exercise: Building a Responsive Page with the Fluid Grid Layout Feature

Contents. Downloading the Data Files Centering Page Elements... 6

Essential HTML & CSS for WordPress. Mark Raymond Luminys, Inc mraymond@luminys.com

Responsive Web Design Creative License

Further web design: Cascading Style Sheets Practical workbook

jquery Tutorial for Beginners: Nothing But the Goods

CST 150 Web Design I CSS Review - In-Class Lab

CIS 467/602-01: Data Visualization

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

ICE: HTML, CSS, and Validation

The Essential Guide to HTML Design

Learning Web Design. Third Edition. A Beginner's Guide to (X)HTML, Style Sheets, and Web Graphics. Jennifer Niederst Robbins

Web layout guidelines for daughter sites of Scotland s Environment

Web Developer Jr - Newbie Course

User Guide for Smart Former Gold (v. 1.0) by IToris Inc. team

Web Design with CSS and CSS3. Dr. Jan Stelovsky

WEB DEVELOPMENT IA & IB (893 & 894)

Web Authoring CSS. Module Descriptor

Web Design and Databases WD: Class 7: HTML and CSS Part 3

WEB DESIGN COURSE CONTENT

CSS for Page Layout. Key Concepts

Web Designing with UI Designing

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

Last week we talked about creating your own tags: div tags and span tags. A div tag goes around other tags, e.g.,:

Selectors in Action LESSON 3

WordPress and HTML Basics

Joomla! template JSN Mico Customization Manual

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Create Your own Company s Design Theme

Microsoft Expression Web Quickstart Guide

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

How to Properly Compose HTML Code : 1

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

Introduction to Web Development

Web Design and Development ACS Chapter 9. Page Structure

The Essential Guide to HTML Design

Introduction to Adobe Dreamweaver CC

MCH Strategic Data Best Practices Review

Positioning Container Elements

CSS - Cascading Style Sheets

How To Design A Website For The Decs

Web Development 1 A4 Project Description Web Architecture

Coding HTML Tips, Tricks and Best Practices

A quick guide to. Creating Newsletters

CS134 Web Site Design & Development. Quiz1

Base template development guide

HOW Interactive Design Conference 2013

BT MEDIA JOOMLA COMPONENT

Development Perspective: DIV and CSS HTML layout. Web Design. Lesson 2. Development Perspective: DIV/CSS

Designing HTML s for Use in the Advanced Editor

Chapter 1. Introduction to web development

Extended Reference for Freeway 7

DESIGNING MOBILE FRIENDLY S

CSS. CSS - cascading style sheets CSS - permite separar num documento HTML o conteúdo do estilo. ADI css 1/28

Chapter 1 Introduction to web development and PHP

Programming exercises (Assignments)

Caldes CM12: Content Management Software Introduction v1.9

Customizing Confirmation Text and s for Donation Forms

OPENTABLE GROUP SEARCH MODULE GETTING STARTED ADD RESERVATIONS TO YOUR WEBSITE

^/ CS> KRIS. JAMSA, PhD, MBA. y» A- JONES & BARTLETT LEARNING

Responsive HTML and Drupal

LRB Portfolio User Guide

Adobe Illustrator CS6. Illustrating Innovative Web Design

Create a Poster Using Publisher

<?xml version= 1.0?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN

What is CSS? Official W3C standard for controlling presentation Style sheets rely on underlying markup structure

Introduction. If you have any questions along the way, feel free to contact our support team at mailchimp.com/support. Now, let s get started.

Joomla! template JSN Boot Customization Manual

INSTANT MAGAZINE QUICK GUIDE

Principles of Web Design 6 th Edition. Chapter 12 Responsive Web Design

Dreamweaver CS4 Day 2 Creating a Website using Div Tags, CSS, and Templates

Appendix H: Cascading Style Sheets (CSS)

CREATING A NEWSLETTER IN ADOBE DREAMWEAVER CS5 (step-by-step directions)

Stylesheet or in-line CSS CSS attributes, used in stylesheets or in-line, can define:

Terminal 4 Site Manager User Guide. Need help? Call the ITD Lab, x7471

Lab 2: Visualization with d3.js

Web Development I & II*

JOOMLA 2.5 MANUAL WEBSITEDESIGN.CO.ZA

HTML5 & CSS3. ( What about SharePoint? ) presented

Designing HTML ers

How To Customize A Forum On Vanilla Forum On A Pcode (Forum) On A Windows (For Forum) On An Html5 (Forums) On Pcode Or Windows 7 (Forforums) On Your Pc

Interspire Website Publisher Developer Documentation. Template Customization Guide

HTML and CSS. Elliot Davies. April 10th,

Intro to Web Design. ACM UIUC

Transcription:

WRITE BETTER HTML BY WRITING BETTER CSS

THE ROYAL WE Chris Coyier @chriscoyier

BETTER? 1 Less of it 2 More Semantic 3 More Accessible 4 Futureproof // Speed // Maintainability // SEO // Happy People

123

1 HOW WUFOO DOES CSS

RULES Only 2 CSS files per page (Global + Site Section) These 2 are made from combined smaller files (like design patterns or site sub sections) Versioned in production (dynamic.13432.css) Timestamped in development (dynamic.css?time=xxx) No inline styles or <style> blocks Reuse everything (e.g. table.css) Work in chunks (e.g. print.css)

SIMPLIFIED SITE STRUCTURE

GLOBAL CSS

GLOBAL CSS

SITE SECTION CSS

SITE SECTION CSS

<!DOCTYPE html> <head> {autoversion}/css/global/dynamic.css{/autoversion} {autoversion}/css/landing/dynamic.css{/autoversion} Smarty function (could be any server side language)

.htaccess AddHandler application/x-httpd-php.php.html.xml.css.js

/css/global/dynamic.css <?php require_once($globals['root'].'/library/services/ AutoVersion.php'); $filearray = array( '/css/global/structure.css', '/css/global/buttons.css', '/css/global/lightbox.css', '/css/global/form.css' ); $av = new AutoVersion(); $av->fly($dynamicurl,$filearray);?>

/css/landing/dynamic.css <?php require_once($globals['root'].'/library/services/ AutoVersion.php'); $filearray = array( '/css/landing/structure.css', '/css/landing/table.css', '/css/landing/else.css', '/css/landing/signup.css', '/css/landing/tour.css' ); $av = new AutoVersion(); $av->fly($dynamicurl,$filearray);?>

AutoVersion function 1) Fetches all files 2) Combines together 3) Minifies 4) Adds version number

<!DOCTYPE html> <head> <link rel="stylesheet" href="/css/global/dynamic.1234.css"> <link rel="stylesheet" href="/css/landing/dynamic.1234.css">

global/dynamic.css Loaded on every page of site Put as much as practical in here. User only loads this file once, so maximizes use of browser cache. Common design patterns are in here (buttons.css, lightbox.css, forms.css)

area/dynamic.css Loaded in specific area of site Less common design patterns in here (graph.css, calendar.css, table.css)

global /css/global/structure.css /css/global/buttons.css /css/global/lightbox.css /css/global/form.css area /css/admin/manager.css

global /css/global/structure.css /css/global/buttons.css /css/global/lightbox.css /css/global/form.css area /css/widgets/datagrid.css /css/global/filter.css /css/global/calendar.css /css/global/quicksearch.css /css/entries/structure.css /css/entries/print.css

global /css/global/structure.css /css/global/buttons.css /css/global/lightbox.css /css/global/form.css area /css/docs/docs.css /css/global/table.css

ALL CSS is in /css/ organized by site section

2 DON T OVER THINK IT

Good thinking Well intentioned BIG FANCY STYLE GUIDE Primary color #BADA55 / Secondary color #F00 Headers should be 20px from navigation and 15px from following content Logo should have 30px of padding around it Links should have 1px dotted bottom borders

that s what GLOBAL.CSS is for

BY SECTION NEED TO DEVIATE? Really? Do you?

STYLE ONLY NEED TO DEVIATE? Really? Do you?

TOTALLY UNIQUE NEED TO DEVIATE? Really? Do you?

DON T OVER THINK IT

3 :visited PSEUDO ELEMENTS :hover :active :link pseudo selectors class :first-child :last-child :nth-child() :nth-of-type() :enabled :disabled :checked :indeterminate :focus :target :root :lang() http://css-tricks.com/pseudo-class-selectors/

:before :after

HTML <div>in</div> CSS div:before { content: "Robots "; } In

HTML <div>in</div> CSS div:before { content: "Robots "; } div:after { content: " Disguise"; } Robots In Disguise

So what s with the different name? Pseudo selectors select elements that already exist (perhaps in different states). Pseudo elements create new content that doesn t exist (yet).

::before ::after ::first-line ::first-letter

:before :after :first-line :first-letter

HTML <div>in</div> CSS div:before { content: "Robots "; } div:after { content: " Disguise"; } Robots In Disguise

Resulting HTML (sorta) <div> In </div>

Resulting HTML (sorta) Robots <div> In </div> Disguise Not before/after the element...

Resulting HTML (sorta) <div> Robots In Disguise </div> It s before/after the content inside.

Resulting HTML (sorta) <div> <h1>blah blah blah</h1> <p>more stuff</p> Nothing to see here. </div>

Resulting HTML (sorta) <div> Robots <h1>blah blah blah</h1> <p>more stuff</p> Nothing to see here. Disguise </div>

CAMELOT! CAMELOT! CAMELOT! It s only a model... (Not really in DOM)

Not for no content elements <img src= robot.jpg alt= Robot > <input type= email name= email /> <br> Allows but shouldn t Styles as if was inside Checkboxes Radio Buttons

HTML <a class= button href= http://wufoo.com/gallery/ > <img src= /images/icon_gallery.png alt= > Visit Our Form Gallery </a> CSS.button { /* Awesome gradients and stuff */ }.button img { /* Probably some margin and stuff */ }

alt="" equals That s not important. Screen readers don t need to see that.

alt="" equals Then get that mothersucker out of your HTML

HTML <a class= button button-gallery href= http://wufoo.com/gallery/ > Visit Our Form Gallery </a> CSS.button { /* Awesome gradients and stuff */ }.button-gallery:before { content: url(/images/icon_gallery.png); }

x200 <a class= button href= http://wufoo.com/gallery/ > <img src= /images/icon_gallery.png alt= > Visit Our Form Gallery </a> 200 extra lines of HTML 200 places you aren t being semantic 200 places you need to change one-by-one 200 opportunities to be more efficient

<html style= background: yellow; > That s a website. It s abstract. Deal with it.

CSS

CSS html { background: red; }

Efficiency!

<a class= button button-gallery href= http://wufoo.com/gallery/ > Visit Our Form Gallery </a> x200.button-gallery:before { content: url(/images/icon_gallery.png); content: ; display: inline-block; width: 16px; height: 16px; background-image: url(/images/sprite.png); background-position: -32px -32px; }

spritecow.com

spriteme.org

RABBLE RABBLE RABBLE!

HTML <h1></h1> <h2></h2> CSS h1:before { content: Wufoo ; } h2:before { content: Making forms easy + fast + fun ; }

Bad for accessibility Bad semantically Bad for SEO

SCREEN READERS NVDA Jaws Window Eyes VoiceOver (OS X) doesn t read doesn t read doesn t read does read Testing (mostly) by Lucica Ibanescu http://cssgallery.info/testing-the-accessibility-of-the-css-generated-content/

What can content be?.thing:before { content:? }

TEXT / STRING content: $ ; content: \0022 ;

IMAGE Behaves like an <img> content: url(i/icon-smile.png); content: -webkit-linear-gradient(...); Needs dimensions

ATTRIBUTE content: attr(href); content: attr(data-city);

On list items COUNTER content: counter(li); counter-increment: li; counter-reset: li; On list

NOTHING content: ;

HTML content: <h1>nope</h1> ;

TEXT / STRING <div class="price">30</div> <div class="price" lang="cn">100</div> [lang= cn ].price:before,.price[lang= cn ]:before { content: \00a5 ; }

COUNTER ol { counter-reset: li; } ol > li:before { content: counter(li); counter-increment: li; } http://www.456bereastreet.com/lab/styling-ordered-list-numbers/

ATTRIBUTE <a href= # data-tooltip= is hot. > Your mom </a> a[data-tooltip] { position: relative; } a[data-tooltip]:after { content: attr(data-tooltip); position: absolute; /* Fancy styles */ opacity: 0; } a[data-tooltip]:hover:after { opacity: 1; }

COMBINING WITH MEDIA QUERIES

mobile portrait mobile landscape tablet small monitor large monitor http://css-tricks.com/css-media-queries/

You can t talk about Pseudo Elements without talking about... Nicolas Dr. Pseudo Element Gallagher http://nicolasgallagher.com/ @necolas

Shapes! These are easy. These are less easy.

.star { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid red; position: relative; }.star:after { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 100px solid red; position: absolute; content: ""; top: 30px; left: -50px; }

http://css-tricks.com/examples/shapesofcss/

http://nicolasgallagher.com/pure-css-gui-icons/demo/

Remember, CSS TWO not THREE Browser Support CSS-Tricks 97% 85% Other tech 92% 3.5+ 3.0- positioning issues 1+ 9+ 8 :: / :hover / z-index 7-1.3+ 6+ http://css-tricks.com/browser-support-pseudo-elements/

MORE http://css-tricks.com/9516-pseudo-element-roundup/

Links http://necolas.github.com/normalize.css/ http://snook.ca/archives/html_and_css/font-size-with-rem http://particletree.com/notebook/automatically-version-your-css-and-javascript-files/ http://css-tricks.com/855-specifics-on-css-specificity/ Photos http://www.flickr.com/photos/webel/347801397/ Type Gotham Condensed Gotham Rounded TUNGSTEN Whitney

Thanks! http://bit.ly/???