Overview. Part I: Portraying the Internet as a collection of online information systems HTML/XHTML & CSS

Similar documents
CSS how to display to solve a problem External Style Sheets CSS files

CSS.

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em>

Comm 244 Week 3. Navigation. Navigation. Websites need a formalized system of links to allow users to navigate the site

CSS: The Basics CISC 282 September 20, 2014

XHTML & CSS CASCADING STYLE SHEETS

Navigation. Websites need a formalized system of links to allow users to navigate the site

CSS stands for Cascading Style Sheets Styles define how to display HTML elements

ITNP43: HTML Lecture 4

What is CSS? NAME: INSERT OPENING GRAPHIC HERE:

Shane Gellerman 10/17/11 LIS488 Assignment 3

Title: Dec 11 3:40 PM (1 of 11)

Lab Introduction to Cascading Style Sheets

Introduction to WEB PROGRAMMING

Assignments (4) Assessment as per Schedule (2)

CSCB20 Week 7. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

HyperText Markup Language (HTML)

CS134 Web Site Design & Development. Quiz1

Cascading Style Sheets (CSS)

HTML & CSS. Lesson 1: HTML Basics Lesson 2: Adding Tables Lesson 3: Intro to CSS Lesson 4: CSS in more detail Lesson 5: Review

GIMP WEB 2.0 MENUS. Before we begin this tutorial let s visually compare a standard navigation bar and a web 2.0 navigation bar.

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

Lab 4 CSS CISC1600, Spring 2012

Designing and Developing a Website. December Sample Exam Marking Scheme

HTML/XML. HTML Continued Introduction to CSS

Introduction to Cascading Style Sheet (CSS)

Cascading Style Sheets. Overview and Basic use of CSS

Groupings and Selectors

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

CASCADING STYLE SHEET CSS

ICT IGCSE Practical Revision Presentation Web Authoring

HTML and CSS: An Introduction

Text and Layout. Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11. This presentation 2004, MacAvon Media Productions

In the early days of the Web, designers just had the original 91 HTML tags to work with.

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

COSC 2206 Internet Tools. CSS Cascading Style Sheets

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

Reading 2.2 Cascading Style Sheets

Comp-206 : Introduction to Software Systems Lecture 23. Alexandre Denault Computer Science McGill University Fall 2006

CMPT 165 Unit 2 Markup Part 2

Introduction to HTML and CSS. Arts and Humanities in the Digital Age 2018 CHASE DTP Dr. Paul Gooding

CISC1600-SummerII2012-Raphael-lec3 1

Part A Short Answer (50 marks)

Cascading style sheets, HTML, DOM and Javascript

Introduction to Web Tech and Programming

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

CSS: Cascading Style Sheets

HTML Hyperlinks (Links)

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

CSC9B1: Essential Skills WWW 1

Creating and Building Websites

Web Design and Development ACS-1809

What is XHTML? XHTML is the language used to create and organize a web page:

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

Three Ways to Use CSS:

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

CHAPTER 4 CASCADING STYLE SHEETS BASICS KEY CONCEPTS

History of the Internet. The Internet - A Huge Virtual Network. Global Information Infrastructure. Client Server Network Connectivity

Positioning in CSS: There are 5 different ways we can set our position:

CSS: Cascading Style Sheets

Dreamweaver: Portfolio Site

COMP519 Web Programming Autumn Cascading Style Sheets

ID1354 Internet Applications

Using Dreamweaver CS6

Chapter 11 CSS2. Presented by Thomas Powell. Slides adopted from HTML & XHTML: The Complete Reference, 4th Edition 2003 Thomas A.

CITS1231 Web Technologies. Introduction to Cascading Style Sheets

CSS: formatting webpages

Chapter 7 Typography, Style Sheets, and Color. Mrs. Johnson

Micronet International College

Vebra Search Integration Guide

Styles, Style Sheets, the Box Model and Liquid Layout

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

CSE 154 LECTURE 3: MORE CSS

CSS Cascading Style Sheets

Web Programming HTML CSS JavaScript Step by step Exercises Hans-Petter Halvorsen

Chapter 4 CSS basics

HTML & CSS November 19, 2014

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

Cascading Style Sheets Level 2

Using Dreamweaver CS6

Controlling Appearance the Old Way

Exam Format: Multiple Choice, True/False, Short Answer (3 points each 75 points total) Write-the-page (25 points)

Methods for configuring Cascading Style Sheets. Applying style to element name selectors. Style Rule Basics. CMPT 165: Cascading Style Sheets

Web Development & Design Foundations with HTML5, 8 th Edition Instructor Materials Chapter 3 Test Bank

Page Layout Using Tables

Which is why we ll now be learning how to write in CSS (or cascading sheet style)

Using Dreamweaver CS6

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

CIS 228 (Fall 2011) Exam 2, 11/3/11

Design Project. i385f Special Topics in Information Architecture Instructor: Don Turnbull. Elias Tzoc

HTML and CSS COURSE SYLLABUS

Dreamweaver CS3 Lab 2

Transcription:

CSS

Overview Part I: Portraying the Internet as a collection of online information systems Part II: Design a website using HTML/XHTML & CSS

XHTML validation

What is wrong? <!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/xhtml" xml:lang="en" lang="en"> <html> <head> <title>this bit goes in the titlebar</title> </head> <body> <h1>this is the heading of the page</h1> <p><i>this is a paragraph</i></p> <p>this is another paragraph</p> </body> </html> Two opening <html> tags

Some smaller errors Remember: Always need opening and closing tags Single tags need to be closed too: <br/> Nesting tags <p><i>some italic text</i></p> <i><p>some italice text</i></p> Single tags also need to be closed off: <br> <br/>

If your document still doesn t validate Maybe not strict XHTML Do you have font colours? CSS to the rescue: Cascading Style Sheets

W3C creates CSS Standard World Wide Web Consortium (W3C) Created HTML 4.0 standard (and in turn XHTML) Created CSS in addition to separate style from content All major browsers support Cascading Style Sheets.

XHTML & CSS XHTML : only content Colour, fonts, style of text etc: CSS document

First css <!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/xhtml"> <head> <title>simple css example</title> </head> <body> <h1>this is a heading</h1> <p>this is a paragraph</p> </body> </html>

Your first css

Your first css <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <link rel="stylesheet" type="text/css" href="firststyle.css" /> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>simple css example</title> </head> <body> <h1>this is a heading</h1> <p>this is a simple paragraph</p> </body> </html>

Stylesheet link <link rel="stylesheet" type="text/css" href="firststyle.css" /> Shows that the document will use a stylesheet href (remember the <a href= > link tag?) Shows where the stylesheet is and what its called

The css file: firststyle.css h1 {color: red}

Your first css page

Adding to our style sheet h1 {color: red} p{ font-family: "lucida calligraphy", arial, 'sans serif'; }

Adding to our style sheet

Changing background colour h1 {color: red} p{font-family: "lucida calligraphy", arial, 'sans serif';} body{ background-color:gray; }

Changing background colour

Changing paragraph alignment h1 { color: red } p { font-family: "lucida calligraphy", arial, 'sans serif'; text-align: right }

Changing paragraph alignment

Why CSS? Font tags (change heading colour & paragraph colour) Align tags (change paragraph alignment) Body tag (add bg-color to <body> tag)

An example from CSS Zen Garden: Same content, different stylesheet http://www.csszengarden.com/

An example from CSS Zen Garden: Same content, different stylesheet http://www.csszengarden.com/

An example from CSS Zen Garden: Same content, different stylesheet http://www.csszengarden.com/

An example from CSS Zen Garden: Same content, different stylesheet http://www.csszengarden.com/

You have got valid XHTML W3C validator checks you XHTML for errors and conformance to standards (STRICT or TRANSITIONAL) W3C CSS validator checks your CSS for errors and conformance to standards

http://jigsaw.w3.org/css-validator

CSS Syntax CSS syntax consists of 3 parts: Selector{Property:Value} You ve seen this already in our simple example: h1 {color: red} p { font-family: "lucida calligraphy", arial, 'sans serif'; text-align: right } body {background-color:gray}

CSS Syntax: grouping styles Grouping selectors: We can have: h1 {color: red} h2 {color: red} h3 {color: red} But we can also say: h1,h2,h3 {color: red} Think again of uniform styles & saving time! Easier to change this one style in css file than change all 3 above

CSS Syntax: The Class Attribute The Class attribute: p{ font-family: "lucida calligraphy", arial, 'sans serif } p.right{text-align: right} p.left{text-align: left} p.center{text-align: center}

CSS Syntax: The Class Attribute <!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/xhtml"> <head> <title>simple css example</title> <link rel="stylesheet" type="text/css" href="firststyle.css" /> </head> <body> <h1>this is a heading</h1> <p class="right">this is a simple paragraph</p> <p class="center">this is a simple paragraph</p> <p class="left">this is a simple paragraph</p> </body> </html>

CSS Syntax: The Class Attribute

Generic Class Attributes Suppose we want to have h1, h2 & p have center classes: h1.center {text-align: center} p.center {text-align: center} h2.center {text-align: center} To simplify, we can make one class attribute usable by all these (h1, h2 & p).center {text-align: center}

Generic Class Attributes h1 { color: red } p{ } font-family: "lucida calligraphy", arial, 'sans serif';.right{text-align: right}.left{text-align: left}.center{text-align: center} body{background-color:gray;}

Generic Class Attributes <!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/xhtml"> <head> <title>simple css example</title> <link rel="stylesheet" type="text/css" href="firststyle.css" /> </head> <body> <h1 class= center >This is a heading</h1> <p class="right">this is a simple paragraph</p> <p class="center">this is a simple paragraph</p> <p class="left">this is a simple paragraph</p> </body> </html>

Generic Class Attributes

Using <span></span> So: What if we don t want to change the style of a whole paragraph with: p{ font-family: "lucida calligraphy", arial, 'sans serif'; } But just the simple part of this is a simple paragraph Use a generic class attribute combined with the <span> tag:.nicefont{ font-family: "lucida calligraphy", arial, 'sans serif'; }

Using <span></span> <!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/xhtml"> <head> <title>simple css example</title> <link rel="stylesheet" type="text/css" href="firststyle.css" /> </head> <body> <h1 class="center">this is a heading</h1> <p class="right">this is a <span class="nicefont">simple</span> paragraph</p> <p class="center">this is a <span class="nicefont">simple</span> paragraph</p> <p class="left">this is a <span class="nicefont">simple</span> paragraph</p> </body> </html>

Using <span></span>

Remember the <div></div> tag? <!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/xhtml"> <head> <title>simple css example</title> <link rel="stylesheet" type="text/css" href="firststyle.css" /> </head> <body> <h1 class="center">this is a heading</h1> <div class= nicefont > <p class="right">this is a simple paragraph</p> <p class="center">this is a simple paragraph</p> <p class="left">this is a simple paragraph</p> </div> </body> </html>

Remember the <div></div> tag?

Background Images in CSS Some people have already added a background image to their XHTML <body background= leaves.gif ></body> With CSS, we can do more advanced things with our backgrounds

Background Images in CSS

Move our background to CSS file body{ background-color:gray; background-image: url("leaves.gif"); }

Move our background to CSS file

Stop the background repeating? body{ background-color:gray; background-image: url("leaves.gif"); background-repeat: no-repeat; }

Stop the background repeating?

Fixing the background body{ background-color:gray; background-image: url("leaves.gif"); background-repeat: no-repeat; background-attachment: fixed }

Positioning the background body{ background-color:gray; background-image: url("leaves.gif"); background-repeat: no-repeat; background-attachment: fixed; background-position: bottom }

CSS Syntax: Comments In XHTML: Comments look like <!-- a comment in XHTML --> CSS comments, similarly, can be used to increase the readability of your CSS code, especially if you make use of shorthand format when writing your CSS rules: /* a comment in css */

Using <div></div> No visible difference using <div></div> But remember - structural tags: Don t alter the presentation of the document Show structure or meaning of document In this case: <div></div> allows us to split our document into sections CSS defines how <div></div> sections are presented

CSS for how <div></div> are displayed <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>positioning In CSS</title> <link href="mystyle.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="one">one</div> <div class="two">two</div> <div class="three">three</div> <div class="four">four</div> </body> </html>

CSS for how <div></div> are displayed div{ } position: relative; width: 100px; height: 100px; color: black; text-align: center div.one{background-color: red} div.two{background-color: green} div.three{background-color: blue;} div.four{background-color: yellow}

CSS for how <div></div> are displayed

CSS for how <div></div> are displayed <div></div> define: The size of area covered (using width and height) The position of the text in the tag (centered here) So what does the position: relative part mean?

Positioning: Relative & Absolute Relative: Item follows previous item in layout Default positioning Absolute: Specify exact position of element on page Where is should be displayed in terms of either: The page itself Other things on the page

Absolute positioning div{ position: absolute; width: 100px; height: 100px; color: black; text-align: center } div.one{background-color: red} div.two{background-color: green} div.three{background-color: blue;} div.four{background-color: yellow}

Where did one,two,three go?

Change position slightly div{ position: absolute; width: 100px; height: 100px; color: black; text-align: center } div.one{background-color: red; left:0px; top:0px} div.two{background-color: green; left:25px; top:25px} div.three{background-color: blue; left:50px; top:50px} div.four{background-color: yellow; left:75px; top:75px}

Change position slightly

Does four always have to be on top? Absolute positioning: Lets us specify by pixel where things go Allows us to overlap areas of our webpage defined by <div></div> tags Can we specify order that they overlap? i.e. can we stack them by: two, four, three, one instead of four, three, two, one?

Z-index Think of page in terms of x, y & z coordinates: Y 0 3 X Z

How do things stack up? div{ position: absolute; width: 100px; height: 100px; color: black; text-align: center } div.one{background-color: red; z-index:0; left:0px; top:0px} div.two{background-color: green; z-index:3; left:25px; top:25px} div.three{background-color: blue; z-index:1; left:50px; top:50px} div.four{background-color: yellow; z-index:2; left:75px; top:75px}

How do things stack up?