Cascading Style Sheets (CSS)



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

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

ITNP43: HTML Lecture 4

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

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

Selectors in Action LESSON 3

Using Style Sheets for Consistency

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

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

Advanced Web Design. Zac Van Note.

CIS 467/602-01: Data Visualization

Outline of CSS: Cascading Style Sheets

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

HTML5 and CSS3 Design with CSS Page 1

Web Development 1 A4 Project Description Web Architecture

CSS - Cascading Style Sheets

ICE: HTML, CSS, and Validation

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

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

HTML, CSS, XML, and XSL

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

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

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

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

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

How to Properly Compose HTML Code : 1

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

Web Authoring CSS. Module Descriptor

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

Style & Layout in the web: CSS and Bootstrap

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

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 (

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

Cascading Style Sheets

CSS for Page Layout. Key Concepts

Interactive Data Visualization for the Web Scott Murray

Create Webpages using HTML and CSS

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

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

HTML TIPS FOR DESIGNING

Web Publishing Basics 2

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

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

Creating a Resume Webpage with

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

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

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Responsive Web Design Creative License

Fast track to HTML & CSS 101 (Web Design)

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

JJY s Joomla 1.5 Template Design Tutorial:

Building Your Website

USD WEB SERVICES ADOBE DREAMWEAVER CSS DEVELOPMENT

Designing HTML s for Use in the Advanced Editor

How to code, test, and validate a web page

HTML and CSS. Elliot Davies. April 10th,

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

Web Development I & II*

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

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

Using an external style sheet with Dreamweaver (CS6)

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

8 STEPS TO CODE KILLER RESPONSIVE S

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

LAB MANUAL CS (22): Web Technology

WEB DEVELOPMENT IA & IB (893 & 894)

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE WEB EDITING

Introduction to Web Design Curriculum Sample

Website Planning Checklist

CS134 Web Site Design & Development. Quiz1

An Attribute is a special word used inside tag to specify additional information to tag such as color, alignment etc.

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Web Design I. Spring 2009 Kevin Cole Gallaudet University

Basic Website Maintenance Tutorial*

Introduction to Web Development

GUIDE TO CODE KILLER RESPONSIVE S

Script Handbook for Interactive Scientific Website Building

MCH Strategic Data Best Practices Review

Creating a Web Page Using HTML, XHTML, and CSS: The Basics

A send-a-friend application with ASP Smart Mailer

Web Design and Development ACS Chapter 9. Page Structure

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

Introduction to Web Technologies

Chapter 2 HTML Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Madison Area Technical College. MATC Web Style Guide

Web Developer Jr - Newbie Course

Microsoft Expression Web Quickstart Guide

Base template development guide

BASICS OF WEB DESIGN CHAPTER 2 HTML BASICS KEY CONCEPTS COPYRIGHT 2013 TERRY ANN MORRIS, ED.D

HeuTX Riders \ A HOLISTIC APPROACH TO WEB DESIGN

Basic tutorial for Dreamweaver CS5

Campaign Guidelines and Best Practices

Professional & Workgroup Editions

Table of Contents Find out more about NewZapp

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

Web Design & Development - Tutorial 04

Web layout guidelines for daughter sites of Scotland s Environment

Creating Web Pages with Dreamweaver CS 6 and CSS

Lesson Review Answers

Transcription:

Cascading Style Sheets (CSS) W3C standard for defining presentation of web documents (way documents are displayed or delivered to users typography, colours, layout etc) Presentation separated from content Presentational elements controlled by author rather than browser W3C recommendations CSS1 CSS2 (incorporates and extents CSS1)

Benefits of CSS More scope in presentation controls Less work (particularly if using external style sheets) Potentially smaller documents Potentially more accessible documents Presentation HTML is being used less and less CSS well supported by browsers

How CSS works Start with HTML or XHTML document referred to as structural layer upon which presentation layer is applied Write rules for how element should look rule targets an element and lists properties to be applied Attach styles to document

Rule Syntax selector{property:value;} declaration selector defines element to be styled Declaration style or display instructions Example styling paragraph selector: p{font-size: 11px; font-weight: bold;}

Adding Style to a Document Inline Style to style an individual element within the HTML tag for that element Example: <h1 style= color: red > This is a red heading</h1> Note: style is tied to individual content elements Note use of quotes

Adding Style to a Document Embedded Style style embedded in a block at top of HTML document, within <head> tags Syntax: <style>..</style> Example: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN HTTP://WWW.W3.ORG/TR/xhtml1/DTD/xhtml1-strict.dtd > <html xmlns=http://www.w3.org/1999/xhtm sml:land= en lang= en > <head> <style type= text/css > h1{color:#666;} p{font-size=90%; font-family: Verdana, sans-serif;} </style> <title>style Sheets</title> </head>. - Styles all instances of h1 and p in the document

Adding Style to a Document External Style Sheets style rules in separate document. Pages link to this document External style sheet is text file with suffix.css Style for whole web site altered by just altering external style sheet

External Style Sheets Style sheet document must contain at least one style rule. Contains no HTML tags Comments: /* This is a comment*/

Linking to external style sheets Link: <head> <link rel= stylesheet href= pathname/stylesheet.css type= text/css /> </head> rel defines linked document s relation to current document href provides address for stylesheet Note: more than one stylesheet can be linked, all stylesheets will apply

Linking to external style sheets Importing: <style type= text.css > <!-- @import url(http://pathname/stylesheet.css); p{font-face: Verdana;} --> </style> Note: multiple style sheets can be applied. With multiple @import functions, last file read takes precedence. @import may be used within a style sheet itself. Placing @import within HTML comments means it will be ignored by browsers not supporting CSS.

Conflicting Rule Styles The Cascade Elements may get presentation instructions from several sources conflict resolved with cascading rules rules passed down until they are overridden by more important style rules The Cascade Style sheet origin Selector specificity Rule order

Style Sheet Origin ascending order of importance 1. User agent style sheets built into browser 2. Reader style sheets (user-created rules) 3. Author style sheets 4. Reader!important style declarations

Author Style Sheets ascending order of importance 1. Linked external sheets 2. Imported style sheets (using @import) 3. Embedded style sheets (using <style>) 4. Inline styles (using <style> in an element tag) 5. Style declarations marked!important

Selector Specificity selector types in ascending order of importance 1. Individual element (e.g. p) 2. Contextual selector (e.g. h1 strong) 3. Class selectors (e.g. p.special) 4. ID selectors (e.g. p#intro)

Rule order If several rules are applied to same element in a single style sheet, last rule is most important For example: h1{color: green;} h1{color: blue;} h1{color: red;} Red is colour applied to h1 headings

The CSS Box Model Every CSS element generates rectangular element box around itself Properties such as borders, margins, background etc. applied to the box Boxes used to position elements and lay out page Components of element box: Content Padding Border Margin

The CSS Box Model

The CSS Box Model Padding, borders and margins are optional if values = 0, they are removed Any background color/image extends into padding area Borders generated by properties like width, color, style Margins always transparent background color/image shows through Width of element is normally content width (note differences between browsers) Top/bottom/sides of element box can have differing styles

CSS Selectors Type selectors Contextual selectors Class and ID selectors Attribute selectors (not well supported) Pseudoclasses Pseudoelements

Type (Element) Selector Targets an element by name applies to all instances of that element. Examples: h1{color:blue;} p{color: red;} Selectors can be grouped h1, h2, p {color:blue;}

Contextual Selectors Based on relation of element to another element e.g. descendent, adjacent sibling Descendent elements target elements contained in (descended from) another element. Example li em{color: green;} means em (emphasised text) is green but only when contained in li Adjacent sibling selector targets elements descended from same parent. Example h1 + p{padding-left: 40} targets first paragraph after a h1 heading.

Class Selectors Target elements you have set up yourself Class attribute used to identify a number of elements as part of a group modify all elements in class in one style rule Class element defined in <head> or in external CSS document. To use the class you invoke it in the HTML tag in <body>

Class Selectors - Example Identify class headerfont in the body: <h1 class= headerfont >This is the header</h1> Code inserted into <head> or external.css file: h1.headerfont{font-size: 15px; font-family:arial; color:red;} Note: period in front of selector signals we are defining a class style Property can be applied to all elements in a class by omitting the tag name

ID Selector Similar to Class Selector, but can only have a single instance of an ID on a page, but may use same ID on several pages on same site ID must uniquely name an element ID s declared in <head> or external.css file Example to invoke an ID: <p id= j0428 >New item added today</p> Declaration in <head>: p#j0428{color:red}

Pseudoselectors Pseudoclasses work like classes, usually for anchors, based on a state, for example: a:link {color:red;} a:visited{color:blue} apply to links, visited links.

Pseudoelements Like inserting fictional elements into document structure for styling. For example: :first-line p:first-line{color: blue; font-size: 20px;} Other pseudoelements :first-letter :before :after