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

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

ITNP43: HTML Lecture 4

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

CIS 467/602-01: Data Visualization

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

Create Webpages using HTML and CSS

ICE: HTML, CSS, and Validation

Web Development 1 A4 Project Description Web Architecture

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

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

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

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

Outline of CSS: Cascading Style Sheets

Cascading Style Sheets

Cascading Style Sheets (CSS)

How to code, test, and validate a web page

Using an external style sheet with Dreamweaver (CS6)

Web Publishing Basics 2

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

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

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

Selectors in Action LESSON 3

Using Style Sheets for Consistency

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

CSS - Cascading Style Sheets

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

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

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

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

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

HTML TIPS FOR DESIGNING

Creating the Surf Shop website Part3 REVISED

Advanced Web Design. Zac Van Note.

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

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

HTML and CSS. Elliot Davies. April 10th,

HTML, CSS, XML, and XSL

LAB MANUAL CS (22): Web Technology

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

Creating HTML authored webpages using a text editor

Style & Layout in the web: CSS and Bootstrap

Building Your Website

Short notes on webpage programming languages

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

Formatting Text in Blackboard

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

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

Script Handbook for Interactive Scientific Website Building

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

Creating a Resume Webpage with

Introduction to Cascading Style Sheets

1 of 8 9/14/2011 5:40 PM

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE WEB EDITING

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

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

Professional & Workgroup Editions

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

Campaign Guidelines and Best Practices

Website Planning Checklist

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

Step by step guides. Deploying your first web app to your FREE Azure Subscription with Visual Studio 2015

Web layout guidelines for daughter sites of Scotland s Environment

HTML COLORS. vlink - sets a color for visited links - that is, for linked text that you have already clicked on.

So we're set? Have your text-editor ready. Be sure you use NotePad, NOT Word or even WordPad. Great, let's get going.

Embedding a Data View dynamic report into an existing web-page

Web Authoring CSS. Module Descriptor

Web Design and Development ACS Chapter 9. Page Structure

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

CSS Techniques: Scrolling gradient over a fixed background

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

Level 1 - Clients and Markup

COMP519 Web Programming Autumn Cascading Style Sheets

How to Manage Your Eservice Center Knowledge Base

BlueHornet Whitepaper

Slicing and Coding the Navigation Background in CSS

<script type="text/javascript"> var _gaq = _gaq []; _gaq.push(['_setaccount', 'UA ']); _gaq.push(['_trackpageview']);

A send-a-friend application with ASP Smart Mailer

JJY s Joomla 1.5 Template Design Tutorial:

How to Properly Compose HTML Code : 1

Responsive Web Design Creative License

USD WEB SERVICES ADOBE DREAMWEAVER CSS DEVELOPMENT

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

With mobile devices and tablets becoming popular for browsing the web, an increasing number of websites are turning to responsive designs to

HTML5 and CSS3 Design with CSS Page 1

CSE 3. Marking Up with HTML. Tags for Bold, Italic, and underline. Structuring Documents. An HTML Web Page File

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

Creating an HTML Document Using Macromedia Dreamweaver

The Web Web page Links 16-3

RESPONSIVE DESIGN BY COMMUNIGATOR

Fast track to HTML & CSS 101 (Web Design)

Introduction to web development and JavaScript

Chapter 8 More on Links, Layout, and Mobile Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

SellerDeck 2014 Responsive Design Guide

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

Designing HTML s for Use in the Advanced Editor

WEB DESIGN LAB PART- A HTML LABORATORY MANUAL FOR 3 RD SEM IS AND CS ( )

mpdf Example 37. Barcodes <?php

Microsoft Expression Web Quickstart Guide

Table of Contents Find out more about NewZapp

Transcription:

Web Design and Databases WD: Class 5: HTML and CSS Part 2 Dr Helen Hastie Dept of Computer Science Heriot-Watt University Some contributions from Head First HTML with CSS and XHTML, O Reilly

Hmm I need some style

Homework- bad design

Managing the Presentation: Stylesheets! HTML markup should be about the structure of a document, not how it should be displayed.! Should ideally keep control of presentation separate: Content Structure Presentation My heading <h1> My.. My heading

Managing the Presentation: Stylesheets! Browsers have default styles (e.g. white background). To change this, use stylesheets! CSS stands for Cascading StyleSheets Presentation My heading

We ll be looking at CSS3 which is backwards compatible with CSS2

interior{ color: cream; material: leather; } exterior { color: pale_blue; } Image from mini.co.uk

CSS syntax! CSS is based on simple rules: selector {property: value;} E.g. p {color:green;}! Selector is (usually) name of the HTML element! e.g. h1, body, li! Property is something like font or color or alignment.! Value is value you want that property to have, e.g. times,green

Selector Property Value p { color:green; }

More than one property Selector Property Value p {! color:green,font-family: times;! }! Property Value

More than one selector Selectors Property Value P, h1, h2 {! color:green,font-family: times;! }! Property Value

Let s work through an example: sweet shop website

<!--Link to CSS file in stylesheets directory--> <link rel="stylesheet" type="text/css" href="stylesheets/sweets.css" /> </head> <body> <h1>sweetstuff Products: Our Lolly Collection</h1> <h2>luscious Lime</h2> <p class="lime"> <img src="images/lime_lolly.png" alt="lime Lolly" /> Bursting with <em>zing</em>. Our lime lolly is one of our best sellers. </p> <h2>strawberry Splurge</h2> <p class="strawberry"> <img src="images/strawberry_lolly.png" alt="strawberry Lolly" /> A classic lolly bringing memories of strawberries and cream in the summer. </p> <h2>omg Orange</h2> <p class="orange"> <img src="images/orange_lolly.png" alt="orange Lolly" /> Super refreshing OMG Orange is an all round favourite. </p> <h2>fruit Swirl</h2> <p class="swirl"> <img src="images/swirl_lolly.png" alt="fruit Swirl" /> Mixing it up with this sumptuous swirl of a lolly. </p> </body> </html>

<!DOCTYPE HTML> <html> <head> <title>sweetstuff Products</title> <!--Link to CSS file in stylesheets directory--> <link rel="stylesheet" type="text/css" href="stylesheets/sweets.css" /> </head> sweets.css

<!--Link to CSS file in stylesheets directory--> <link rel="stylesheet" type="text/css" href="stylesheets/sweets.css" /> </head> <body> <h1>sweetstuff Products: Our Lolly Collection</h1> <h2>luscious Lime</h2> <p class="lime"> <img src="images/lime_lolly.png" alt="lime Lolly" /> Bursting with <em>zing</em>. Our lime lolly is one of our best sellers. </p> <h2>strawberry Splurge</h2> <p class="strawberry"> <img src="images/strawberry_lolly.png" alt="strawberry Lolly" /> A classic lolly bringing memories of strawberries and cream in the summer. </p> <h2>omg Orange</h2> <p class="orange"> <img src="images/orange_lolly.png" alt="orange Lolly" /> Super refreshing OMG Orange is an all round favourite. </p> <h2>fruit Swirl</h2> <p class="swirl"> <img src="images/swirl_lolly.png" alt="fruit Swirl" /> Mixing it up with this sumptuous swirl of a lolly. </p> </body> </html>

Adding italics and links

<!--Link to CSS file in stylesheets directory--> <link rel="stylesheet" type="text/css" href="stylesheets/sweets.css" /> </head> <body> <h1>sweetstuff Products: Our Lolly Collection</h1> <h2>luscious Lime</h2> <p class="lime"> <img src="images/lime_lolly.png" alt="lime Lolly" /> Bursting with <em>zing</em>. Our lime lolly is one of our best sellers. </p> <h2>strawberry Splurge</h2> <p class="strawberry"> <img src="images/strawberry_lolly.png" alt="strawberry Lolly" /> A classic lolly bringing memories of strawberries and cream in the summer. </p> <h2>omg Orange</h2> <p class="orange"> <img src="images/orange_lolly.png" alt="orange Lolly" /> Super refreshing OMG Orange is an all round favourite. </p> <h2>fruit Swirl</h2> <p class="swirl"> <img src="images/swirl_lolly.png" alt="fruit Swirl" /> Mixing it up with this sumptuous swirl of a lolly. </p> </body> </html>

So how do we decide what these look like?

Inheritance! Elements inside <p> inherit the properties of the <p>. For example: <p> <img src="images/lime_lolly.png" alt="lime Lolly" /> Bursting with <em>zing</em>. Our lime lolly is one of our best sellers </p> html body h1 h2 p p p p em img a img img img

Inheritance! Elements inside <p> inherit the properties of the <p>. For example: <p> <img src="images/lime_lolly.png" alt="lime Lolly" /> Bursting with <em>zing</em>. Our lime lolly is one of our best sellers </p> html body h1 h2 p p p p em img a img img img

What if we want the same font throughout?

Move the font up the tree html body h1 h2 p p p p em img a img img img

Move the font up the tree

Over-riding Inheritance html body h1 h2 p p p p em img a img img img

What if we want it to be different?

Override the em font inheritance

What if we have similar types of content we want to look the same?

Adding a Class <p class="lime"> <img src="images/lime_lolly.png" alt="lime Lolly" /> Bursting with <em>zing</em>. Our lime lolly is one of our best sellers. </p>

Adding a class

Adding more classes

Elements can be in more than one class HTML <p class="lime specials"> CSS

Elements can be in more than one class What if all have the same property (e.g. color)? Which rule wins? HTML <p class="lime strawberry orange swirl > CSS

Selector rules! Is there is a CSS rule with that selector?! If not, is there a parent element with a selector?! If not, then use the default

Selector rules! But what about our example? What rule breaks the tie? <p class= lime strawberry orange swirl >! Doesn t matter what order it comes in in the HTML <p class= strawberry orange swirl lime >! It matters about specificity in the CSS file.

How to apply classes This rule selects any <p> This rule selects all members of lime class so a bit more specific This rule selects <p> of lime class so a bit more specific again These rules selects <p> of various class so about the same specificity as above rule

If there still isn t a winner? It s the last rule in the CSS that wins and is applied

Add elements to the tree an colour in those affected by.big rule p.big em ul li body p li.big em CSS li

Add elements to the tree an colour in those affected by.big rule body p.big p ul em li.big li CSS li em

HTML: colour in.big body p.big and li.big *.big ".big p.big p ul em li.big li CSS li em

What s wrong with this.css No HTML in your.css <body> body { background-color:white h1, { gray; font-family:sans-serif; } h2,p { color: } <em> { font-style:italic; } <body> Head First HTML with CSS and XHTML, O Reilly Missing semicolon and } Extra comma Missing property name Missing property value and semicolon HTML tag instead of element name. No HTML in your CSS.

Tables <!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> Also width, height, textalign, padding <table> <caption>caption: A table with not very much in it </caption> <tr><th>heading1</th> <th>heading2</th></tr> <tr><td>row1 col1 data</td><td>row1 col2 data</td></tr> <tr><td>row2 col1 data</td><td>row2 col2 data</td></tr> <tr><td>row3 col1 data</td><td>row3 col2 data</td></tr> </table> </body> </html>

Validation! Guess what: you can validate your CSS files too.! http://jigsaw.w3.org/css-validator/

Comments in CSS /*Set the font for all the descendents of body*/ body { font-family: sans-serif; }

Let s take a break

Crossword Across 1. Used to double check your HTML 6. XHTML is this type of mark-up 7. img is one of the HTML 8. We invented an XML language for these Down 2. These have a name and a value 3. The X in XHTML is for 4. It s good practice to have tags 5. In elements are (4,4) 1 2 8 v a l i d a t o r t c a 6 5 x m r 7 l o w e l r c a s e t r i b u e t n e m e n t s s 4 3 e x t i b c l o s i n g e Modified from Head First HTML with CSS and XHTML, O Reilly

A bit about colours! http://www.w3schools.com/cssref/css_colornames.asp! 147 colour names which are supported by browsers! The 17 standard colours are: aqua, black, blue, fuchsia, gray, grey, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow.

Hex Codes! 16 million different colours using the Hex code http://www.colorpicker.com! http://www.w3schools.com/html/ html_colors.asp #CC6633 Always start with # red green blue

Hex Codes Explained Head First HTML with CSS and XHTML, O Reilly

Hex Codes Explained Head First HTML with CSS and XHTML, O Reilly

Hex Codes Explained Head First HTML with CSS and XHTML, O Reilly Head First HTML with CSS and XHTML, O Reilly

Hex Codes Explained Head First HTML with CSS and XHTML, O Reilly

Hex codes continued! Each character is between 0-15 Head First HTML with CSS and XHTML, O Reilly

! FFFFFF is white! 000000 is black 0% 100% 0 255/255

red green blue #CC6600 Head First HTML with CSS and XHTML, O Reilly

Hex Continued =40% (204/255)* 100=80% (102/255)*100 Head First HTML with CSS and XHTML, O Reilly

Hex code: you try! CC3399! RED: CC= 204/255 = 80%! GREEN: 33 = (3 + (3*16))/255=51/255= 20%! BLUE: 99 = (9 + (9*16))/255= 153/255 =60%

Other ways you ll see colours! a HEX value - like "#ff0000"! an RGB value - like "rgb(255,0,0)"! a color name - like "red"

Summary! HTML elements gives structure! CSS adds style! Rules can apply to one or more selectors which specify which HTML element to apply rule p, h2 { color:green,font-family: times; }! HTML elements can be members of one or more class <p class= lime strawberry orange swirl >! HTML elements can inherit properties! How CSS rules are applied is based on specificity and which rules are last in the CSS file! 3 ways to specify colours

Today s Labs! Part 1: Your home page in HTML! Part 2: CSS exercise! Part 3: Adding style to your homepage! Next time- Accessibility