CSS Crash Course. By Daniel D'Agostino. First drafted: 19 th June 2007 Written on: 19 th October 2008

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

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

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

CSS for Page Layout. Key Concepts

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

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

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

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

Slicing and Coding the Navigation Background in CSS

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

Using Style Sheets for Consistency

Style & Layout in the web: CSS and Bootstrap

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

ITNP43: HTML Lecture 4

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 (

Cascading Style Sheets (CSS)

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

Using an external style sheet with Dreamweaver (CS6)

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

Coding Standards for Web Development

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

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

JJY s Joomla 1.5 Template Design Tutorial:

GUIDE TO CODE KILLER RESPONSIVE S

Outline of CSS: Cascading Style Sheets

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

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

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. Web Design in Nvu Workbook 2

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

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

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

Further web design: Cascading Style Sheets Practical workbook

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

CSS - Cascading Style Sheets

Web Authoring CSS. Module Descriptor

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

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

Kentico CMS, 2011 Kentico Software. Contents. Mobile Development using Kentico CMS 6 2 Exploring the Mobile Environment 1

ICE: HTML, CSS, and Validation

Advanced Web Design. Zac Van Note.

Table of Contents Find out more about NewZapp

Web Design Revision. AQA AS-Level Computing COMP2. 39 minutes. 39 marks. Page 1 of 17

How to Properly Compose HTML Code : 1

HTML and CSS. Elliot Davies. April 10th,

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

Introduction to Adobe Dreamweaver CC

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

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

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

Mobile Web Site Style Guide

CIS 467/602-01: Data Visualization

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

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

HTML5 and CSS3 Design with CSS Page 1

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

SharePoint Designer Tutorial

Designing HTML s for Use in the Advanced Editor

Code View User s Guide

Selectors in Action LESSON 3

A send-a-friend application with ASP Smart Mailer

HTML TIPS FOR DESIGNING

Campaign Guidelines and Best Practices

Advanced Editor User s Guide

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

CS134 Web Site Design & Development. Quiz1

THE. Woork HANDBOOK. A collaborative book about web design and programming

Intro to Web Design. ACM UIUC

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

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

Basic tutorial for Dreamweaver CS5

KOMPOZER Web Design Software

Microsoft Expression Web Quickstart Guide

Creating Web Pages with Dreamweaver CS 6 and CSS

Fast track to HTML & CSS 101 (Web Design)

Web layout guidelines for daughter sites of Scotland s Environment

Level 1 - Clients and Markup

8 STEPS TO CODE KILLER RESPONSIVE S

Responsive Web Design Creative License

The Essential Guide to HTML Design

ART 379 Web Design. HTML, XHTML & CSS: Introduction, 1-2

Introduction to web development and JavaScript

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE WEB EDITING

Web Design and Development ACS Chapter 9. Page Structure

Web Developer Jr - Newbie Course

Create Your own Company s Design Theme

Making Responsive s

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Introduction to Web Design Curriculum Sample

New Perspectives on Creating Web Pages with HTML. Considerations for Text and Graphical Tables. A Graphical Table. Using Fixed-Width Fonts

Web publishing: An introduction to CSS

Web Design and Databases WD: Class 5: HTML and CSS Part 2

CSS Vocabulary and Grammar Basics

You can use percentages for both page elements and text. Ems are used for text,

Joomla! Class Suffix Guides

Creating the Surf Shop website Part3 REVISED

Creator Coding Guidelines Toolbox

BlueHornet Whitepaper

Click on the links below to find the appropriate place in the document

How To Design A Website For The Decs

Transcription:

CSS Crash Course By Daniel D'Agostino First drafted: 19 th June 2007 Written on: 19 th October 2008

Part 1 Introduction to CSS

What is CSS/Why CSS? A language complementary to HTML Separation of structure (HTML) and style (CSS) Centralisation of style in one file modifying one declaration can affect the whole site Allows allocating style to HTML elements defined by complex relationships e.g. A list in a list Note: Like HTML, different browsers interpret CSS differently

Links What can you do with CSS? http://meyerweb.com/eric/css/edge/ http://www.csszengarden.com/ Good reference material http://www.w3schools.com/css/ http://glish.com/css http://www.blooberry.com/indexdot/css/

Kickstart: The HTML side 1.Create a basic HTML file with <head>, <body> etc and some basic content to test with 2.Add the following to the <head> section of your HTML page: <link rel= stylesheet type= text/css href= style.css > Remember to close with /> if you are using XHTML!

Kickstart: The CSS side 1.Create an empty text file called style.css 2.Add the following in the CSS file: body { background-color:#ff0000; } Your page background should become red (equivalent to <body bgcolor= #FF0000 >)

CSS Syntax explained HTML element being designed body { background-color:#ff0000; } properties of an element are listed between curly brackets property subproperty value

CSS Colours explained 3 types of colour values: hex values e.g. #FFFFFF shorthand: #xyz == #xxyyzz RGB values e.g. rgb(255, 255, 255) colour names e.g. white To set: foreground (text) colour use color: background colour use background-color:

More CSS examples background-color:#000000; color:#ffffff; text-decoration:underline; font-weight:bold; font-style:italic; margin-left:5px; padding-right:10%;

CSS property shorthand Consider: font-weight:bold; font-style:italic;...these are both subproperties of font. Shorthand equivalent: font: bold italic;

CSS Text Formatting Examples: color:black; font-weight:bold; font-style:italic; text-decoration:underline; text-align:center; font-family:arial; font-size:18px; References: http://www.w3schools.com/css/css_font.asp http://www.w3schools.com/css/css_text.asp

About Fonts Try to use cross-platform fonts (e.g. Arial) so that site can look the same on different operating systems You can define a list of fonts to use... if the first one is not found, the next one in the list is used e.g. font-family: Verdana, Arial, Helvetica monospace is a family of fixed-width fonts serif vs sans-serif e.g. Times New Roman vs Arial

CSS Borders border left right top bottom width color style width color style width color style width color style

CSS Borders explained Define only one property of one border: border-bottom-width:3px; Define one border entirely: border: solid 2px #CC0000; Define one property of all borders: border-style:dashed; Define all properties of all borders: border: dotted 3px black;

Margins vs Padding Consider a table... a b c d e 1 2 3 4 5 1 10 11 100 101 i ii iv v iii 1 100 10

Margins vs Padding 011 100 padding margin 110 111

CSS Margins and Padding Set individual margins: Set individual padding: margin-left:2px; padding-left:2px; margin-right:4px; padding-right:4px; margin-top:3px; padding-top:3px; margin-bottom:5px; padding-bottom:5px; Set all margins: Set all padding: margin:5px; padding:5px;

CSS Links a:link {...} unvisited link a:visited {...} visited link a:hover {...} mouseover link a:active {...} link with focus Reference: http://www.w3schools.com/css/css_pseudo_classes.asp

Other useful CSS properties display (block, inline,...) visibility (visible, hidden,...) float overflow cursor list-style-type background (color, image, repeat) border-collapse (for tables)

CSS Complex Relationships p img {...} Applies to <img>'s inside <p>'s td, th, table {...} Applies to all of <td>, <th> and <table> p.myclass {...} Applies to <p>'s using the myclass class p#myid {...} Applies to <p>'s using the myid id

CSS Complex Relationships Note: p#myid!= p #myid (with space) p#myid -> all paragraphs defined as myid p #myid -> all elements defined as myid which are in a paragraph Elements with particular attributes: input[type= text ] {...} limited browser support

CSS Inheritance If a property is not defined, its value is usually inherited from that of the parent (containing) element e.g. a paragraph may inherit the <body>'s text colour A value can be explicitly inherited from the parent element using the inherit keyword e.g. color:inherit; useful when a property already has a value but we want to override it with an inherited value

Advanced CSS Further Reading Pseudo-classes Pseudo-elements Generated content

Part 2 CSS Techniques

HTML style attribute Can be used to use CSS directly in an HTML element e.g. <p style= text-align:right; >...</p> Useful for associating CSS with an HTML element that occurs only once (and which thus does not need to be defined in the external CSS file) Eliminates need for HTML layout tags/attributes in such situations

Internal Style Sheets For CSS to be used with only one HTML page...no need to use an external CSS file! Put the following in your <head> section: <style type= text/css > <!-- /* CSS code goes here */ --> </style> HTML comments <!-- --> are important for old non- CSS browsers to ignore the CSS Note: CSS comments are like in C++: /*... */

CSS Classes HTML side: <p class= fancy >...</p> CSS side:.fancy {...} Applies properties of class.fancy to any HTML element that uses that class Classes begin with a dot

CSS IDs HTML side: <h2 id= contents >...</h2> CSS side: #contents {...} Applies properties of class.fancy to any HTML element that uses that class IDs begin with a hash sign Unlike classes, IDs can be used only once in an HTML page

HTML <div>'s HTML divisions are used to group several HTML elements together Useful to apply the same CSS to several elements at once Also useful to group elements structurewise Commonly used to create divisions for navigation and content in the CSS layout

The CSS Layout: History HTML page layout evolved substantially over the years plain pages frames tables...and finally, CSS! Tables are ok but inadequate no logical relation between cells bloat page with presentation details maintenance nightmare

The CSS Layout: <div>'s <div id= navigation > <!-- navigation goes here --> </div> <div id= content > <!-- content goes here --> </div>

CSS Positioning position:absolute; puts element in top-right corner regardless of other elements declared before or after it positioning properties: top:5px; left:10px; right:15px; bottom:20px;

The CSS Layout: How-To Using <div>'s and CSS positioning properties, <div>'s can be placed anywhere on the page This works great, and is used worldwide But... there is a better way! HTML lists can be used for navigation... even if it is horizontal (with display:inline) The HTML <body> itself can be used for content

The Meaning of CSS CSS = Cascading Style Sheets Why Cascading? 1.style attribute 2.id attribute 3.class attribute 4.internal style sheet 5.external style sheet 6.default browser style setting CSS may be defined in various locations. Each of these has a priority. If a property is not defined in the highest priority location, the browser tries to find it in the next location.

CSS Media Different CSS can be applied to different CSS media Useful especially to make your website printer-friendly! Default media type is screen Support for media types is browserdependent although CSS defines them

CSS Media Types screen embossed print handheld all projection aural tty braille tv Reference: http://www.w3schools.com/css/css_mediatypes.asp

Example with Print Media @media print { #navigation { display:none; } } #content { margin-left:0px; }

Multiple Style Sheets <link rel= stylesheet type= text/css href= blue.css title= Blue Theme > <link rel= alternate stylesheet type= text/css href= green.css title= Green Theme > Use several <link>'s to use multiple CSS files Use the title attribute to name them (for user selection)

Importing Style Sheets A style sheet can import properties from another style sheet @import statements must occur before any other property declarations @import url( another.css ); Reference: http://www.w3.org/tr/css2/cascade.html#at-import