Secrets of CSS: Using Cascading Style Sheets. What is CSS? Outline

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

{color:blue; font-size: 12px;}

Web Authoring CSS. Module Descriptor

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

Chapter 7 Page Layout Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Style & Layout in the web: CSS and Bootstrap

Introduction to Adobe Dreamweaver CC

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

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

CSS for Page Layout. Key Concepts

HTML and CSS. Elliot Davies. April 10th,

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

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

Using Style Sheets for Consistency

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

Table of Contents Find out more about NewZapp

Chapter 1. Introduction to web development

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

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

ITNP43: HTML Lecture 4

JJY s Joomla 1.5 Template Design Tutorial:

Slicing and Coding the Navigation Background in CSS

Web Design for Print Designers WEB DESIGN FOR PRINT DESIGNERS: WEEK 6

Coding Standards for Web Development

Further web design: Cascading Style Sheets Practical workbook

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 (

Base template development guide

Outline of CSS: Cascading Style Sheets

CSS 101. CSS CODE The code in a style sheet is made up of rules of the following types

Creating Web Pages with Dreamweaver CS 6 and CSS

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

Web Design & Development - Tutorial 04

Designing HTML s for Use in the Advanced Editor

Contents. Introduction Downloading the Data Files... 2

FETAC Certificate in Multimedia Production. IBaT College Swords. FETAC Certificate in Multimedia Production Web Authoring Dreamweaver 3

Simply download Beepip from and run the file when it arrives at your computer.

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

Cascading Style Sheets (CSS)

Requirements for Developing WebWorks Help

Responsive Web Design Creative License

Microsoft Expression Web Quickstart Guide

COMMONWEALTH OF PENNSYLVANIA DEPARTMENT S OF Human Services, INSURANCE, AND AGING

CIS 467/602-01: Data Visualization

Campaign Guidelines and Best Practices

Creating a Resume Webpage with

CHAPTER 10. When you complete this chapter, you will be able to:

CSS - Cascading Style Sheets

WEB DEVELOPMENT IA & IB (893 & 894)

How to Properly Compose HTML Code : 1

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

GUIDE TO CODE KILLER RESPONSIVE S

Website Login Integration

Introduction to Web Technologies

Basics of HTML (some repetition) Cascading Style Sheets (some repetition) Web Design

Advanced Editor User s Guide

MCH Strategic Data Best Practices Review

RESPONSIVE DESIGN FOR MOBILE RENDERING

Code View User s Guide

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

Klik op deze albums als u de foto s van onze evenementen wil ontdekken.

Basic tutorial for Dreamweaver CS5

MadCap Software. Import Guide. Flare 11

Cascading Style Sheet (CSS) Tutorial Using Notepad. Step by step instructions with full color screen shots

Introduction to web development and JavaScript

Web Development I & II*

SharePoint Designer Tutorial

Web layout guidelines for daughter sites of Scotland s Environment

Chapter 1: Outlook Isn t Going Anywhere Chapter 2: 17 Must-Know Tricks for Outlook 2007, 2010 &

Website Development. 2 Text. 2.1 Fonts. Terry Marris September We see how to format text and separate structure from content.

Web Building Blocks. Joseph Gilbert User Experience Web Developer University of Virginia Library

Dreamweaver CS5. Module 1: Website Development

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

Level 1 - Clients and Markup

01/42. Lecture notes. html and css

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE WEB EDITING

HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout

Fast track to HTML & CSS 101 (Web Design)

Introduction to Web Development

The Essential Guide to HTML Design

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

HTML5 and CSS3 Design with CSS Page 1

Appendix H: Cascading Style Sheets (CSS)

BlueHornet Whitepaper

Web Design I. Spring 2009 Kevin Cole Gallaudet University

Web Design and Development ACS Chapter 9. Page Structure

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

Selectors in Action LESSON 3

Colgate University Website Content Style Guide

Dreamweaver. Introduction to Editing Web Pages

Creating the Surf Shop website Part3 REVISED

Flare Tips and Tricks. Tips and tricks. Importing content Lists. Variables and snippets Condition tags Printed documentation WebHelp.

HTML and CSS 2 Class Meetings Instructor Contact Office Hours: Tuesdays 5:30-7:30 PM Online Class Message List Opt Out of Class

Using an external style sheet with Dreamweaver (CS6)

Using Adobe Dreamweaver CS4 (10.0)

Creator Coding Guidelines Toolbox

Table of Contents THE DESIGNER S GUIDE TO CREATING NEWZAPP DRAG AND DROP TEMPLATES... 6 THE NEWZAPP SYSTEM... 7

A send-a-friend application with ASP Smart Mailer

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

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

Transcription:

Outline Secrets of CSS: Using Cascading Style Sheets David Shaked (Wernick) AlmondWeb Ltd. 02-5712246 david@almondweb.com http://www.almondweb.com 1. What is CSS? 2. Style Sheet Language 3. Creating a Style Sheet 4. Accessibility 5. Other technical issues 6. Where to Learn More Copyright 2008 AlmondWeb Ltd. All rights reserved. 1 2 Purpose of CSS What is CSS? Style language for HTML and XML Separates content from formatting Cross-platform compatibility Viewers: Internet Explorer / Firefox / Opera / Safari / Outlook /... Platforms: Windows / UNIX / Linux / Mac /... Data: HTML / XHTML / XML /... Languages: English / Hebrew / Japanese /... Intended for control of overall appearance Not intended for pixel-level precision Will not replace FrameMaker, Word, and PDF for printing books Copyright 2008 AlmondWeb Ltd. All rights reserved. 3 4 1

Relevance for Technical Writers Most technical writers generate HTML HTML authoring tools require or generate CSS Dreamweaver WebWorks epublisher RoboHelp Flare Word Outlook XML-based workflows output to HTML + CSS HTML Provides Structural Markup <html> <head> <title>peeling Potatoes</title> </head> <body> <h1>how to Peel a Potato</h1> <img src="potatoprocedure.gif"> <p>to peel a potato:</p> <ol> <li>grasp a potato in your left hand.</li> <li>hold the peeler in your right hand.</li> <li>moving the peeler in short, quick motions, scrape the peel from the potato and expose the white.</li> </ol> </body> </html> 5 6 Default Formatting Formatted Appearance 7 8 2

CSS Code Implementing the Format CSS Levels body { font-family:verdana, Arial, Helvetica, sansserif; margin-left:30px; margin-bottom:9px; h1 { color:#ff9933; margin-bottom:24px; margin-top:6px; img { background-color:#ff9933; float:right; width:110px; padding:10px; margin-top:0px; margin-right:20px; border-style:double; border-color:#117788; border-width:3px; ol { list-style-type:loweralpha; list-styleposition:outside; li { margin-bottom:6px; CSS1 1996, 1999 W3C Recommendation CSS2.1 2004 W3C Candidate Recommendation CSS3 Under development Each level includes the previous levels Adds new features 9 10 Features Introduced by CSS Levels CSS1 Basic visual formatting CSS2 Absolute positioning RTL text Selector logic / XML support Audio properties CSS3 Media support Interactivity Selector logic Snaking columns, rounded borders, etc. Browser Support - Vendor Quotes MSIE 6 "Full CSS1" MSIE 7 "Improved support for CSS2.1" Firefox 1.5 "Improved support for CSS2 and CSS3" Safari "The most complete implementation of the CSS specification" Provides a list of supported CSS features 11 12 3

Attaching Styles to an HTML Document Inline <div style="color:red;font-size:18px;"> Style Sheet Language <Style> element <style> body {color: black; font-size:12px; div.bigblue {color:blue; font-size:18px; </style> Linked style sheet <link rel="stylesheet" type="text/css" href="potato.css"> Copyright 2008 AlmondWeb Ltd. All rights reserved. 13 14 Example of Attaching Styles Resulting Display <html> <head> <title>peeling Potatoes</title> <link rel="stylesheet" type="text/css" href="potato.css"> <style> li {color:#117788; </style> </head> <body> <h1 style="text-align:right;">how to Peel a Potato</h1> <img src="potatoprocedure.gif"> <p>to peel a potato:</p> <ol> <li>grasp a potato in your left hand.</li> <li>hold the peeler in your right hand.</li> <li>moving the peeler in short, quick motions, scrape the peel from the potato and expose the white.</li> </ol> </body> </html> 15 16 4

Selectors <p id="me" class="red">a paragraph.</p> Element selector p {font-size:12px; Class selector.red {color:red; p.red {color:red; ID selector #me {font-variant:small-caps; Contextual Selectors <div class="note"> <p><img src="noteicon.png"> A paragraph </p> </div> img {background-color:yellow; Matches any <img> div.note p img {background-color:yellow; Matches only an <img> nested within a <p> nested within a div having class="note" 17 18 Grouping Examples of CSS1 Properties h1 {font-family:arial; h1 {color:blue; h2 {font-family:arial; h2 {color:blue; h1, h2 { font-family:arial; color:blue; Equivalent representations color font-family font-size font-style font-weight text-indent direction background-color background-image background-repeat padding border-color border-style border-width margin width height display float white-space 19 20 5

CSS Box Model margin padding This is an object on an HTML page width Margins Collapse 1st paragraph: margin-bottom:18px; 2nd paragraph: margin-top:6px; Result: 18px between the paragraphs border Equivalent option in Microsoft Word: Tools > Options > Compatibility > Don't use HTML paragraph auto spacing - If selected, 24px between paragraphs 21 - If not selected, 18px between paragraphs (recommended) 22 Pseudo-Classes and Elements a:link {color:#3366ff; a:hover {color:#ff6633; a:active {color:#ff0000; a:visited {color:#336699; Click here for more information p:first-letter {font-size:200%; float:left; Drop capital Cascading: Resolving Rule Conflicts 1. Multiple style sheets Author > User > Browser default 2. Multiple rules More specific selector > Less specific selector 3. Last rule wins Body {font-family:verdana; Body {font-family:arial; Body H1 {font-family:verdana; H1 {font-family:arial; Last rule More specific selector 23 24 6

Example of Conflicting Rules <p class="note">this is a note.</p> p {font-size:10pt; font-weight:normal; color:black; p.note {font-size:12pt; font-weight:bold;.note {font-weight:normal; font-style:italic; Result: 12pt (more specific selector) bold (more specific selector) italic (no conflicting rule) black (no conflicting rule) Best Practices for Style Sheet Design Use inheritance body {font-family:arial,sans-serif;font-size:12px; h1 {font-size:20px; p { Or define each style independently h1 {font-family:arial,sans-serif;font-size:20px; p {font-family:arial,sans-serif;font-size:12px; Avoid mixing the two styles Add comments /* Default style */ body {font-family:arial,sans-serif;font-size:12px; 25 26 CSS Editors Creating a Style Sheet NewsGator TopStyle Westciv StyleMaster Adobe Dreamweaver Notepad Help authoring tools Copyright 2008 AlmondWeb Ltd. All rights reserved. 27 28 7

Example: WebWorks Style Designer WebWorks CSS Output 29 30 Troubleshooting a Style Sheet W3C CSS validator Style checkers built into CSS editors Conflicts between Rules <p class="note">this is a note.</p> p {font-size:10pt; font-weight:normal; color:black; p.note {font-size:12pt; font-weight:bold;.note {font-weight:normal; font-style:italic; Result: 12pt bold italic black 31 32 8

Incomplete Browser Support CSS2 defines an outline property Similar to border but does not occupy space in box model Firefox supports MSIE 7 does not support Imperfect Browser Support All elements are supposed to inherit from <body> In old browsers, table cells <td> failed to inherit Work-around In old CSS code, you are likely to see: body, td { font-family:arial, Helvetica, sans-serif; 33 34 Accessibility for Visually Impaired Users Accessibility Firefox: View > Text Size > Increase MSIE 7: View > Text Size > Largest Copyright 2008 AlmondWeb Ltd. All rights reserved. 35 36 9

CSS Defines Fixed Font Size in Pixels <span class="lead">...<p>andy Ram and Yoni Erlich...</p>... </span>.lead { font-family: Arial, sans-serif; font-size: 12px; font-weight: normal; line-height: 140%; Solution: Define Relative Font Size <span class="lead">...<p>andy Ram and Yoni Erlich...</p>... </span>.lead { font-family: Arial, sans-serif; font-size: 0.75em; font-weight: normal; line-height: 140%; In MSIE 7, enlarging the base font does not affect fixed font sizes In Firefox, enlarging the base font scales all font sizes 1em = font size of parent element Enlarging the parent size enlarges the size of an em 37 38 Effect of Relative Size Definition Firefox: View > Text Size > Increase Other Technical Issues MSIE 7: View > Text Size > Largest 39 Copyright 2008 AlmondWeb Ltd. All rights reserved. 40 10

Scripting Support for CSS When a user clicks a button, link to an alternative style sheet Support multiple browsers (obsolete) Accessibility Modify inline styles Display hidden sections of a page display:none -> display:block Browser-Specific CSS Extensions Behaviors are a Scenario Microsoft extension A user fills in an HTML form offline Internet Explorer only! The user saves the HTML page Default: The page is saved without the form data The user's entries are lost Add a savesnapshot behavior to the CSS code: <style>.ssnapshot {behavior:url(#default#savesnapshot); </style> The page is saved with the form data The user can re-open the page and submit the form 41 42 Unsupported Features Tab stops By design, HTML collapses tabs to space characters Conditional logic Format the second <p> within a <div> in red If the page contains a Warning heading, format the next paragraph in red CSS2 and CSS3 provide partial solutions Browsers do not yet fully support Where to Learn More 43 Copyright 2008 AlmondWeb Ltd. All rights reserved. 44 11

World Wide Web Consortium http://www.w3.org/style/css W3 Schools http://www.w3schools.com/css Specifications Definitive Reference Revision history Links to browsers and tools supporting CSS Links to CSS books and tutorials CSS tutorial Mostly CSS1 Practical reference Interactive examples 45 46 Outline 1. What is CSS? 2. Style Sheet Language 3. Creating a Style Sheet 4. Accessibility 5. Other Technical Issues 6. Where to Learn More Secrets of CSS: Using Cascading Style Sheets David Shaked (Wernick) AlmondWeb Ltd. 02-5712246 david@almondweb.com http://www.almondweb.com 47 Copyright 2008 AlmondWeb Ltd. All rights reserved. 48 12