Web Development & Design Foundations with HTML5

Similar documents
Web Development & Design Foundations with HTML5

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

CHAPTER 4 CASCADING STYLE SHEETS BASICS KEY CONCEPTS

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

CSS: The Basics CISC 282 September 20, 2014

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

CSS Cascading Style Sheets

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

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

CSS Cascading Style Sheets

Reading 2.2 Cascading Style Sheets

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

COSC 2206 Internet Tools. CSS Cascading Style Sheets

CSS.

Appendix D CSS Properties and Values

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

Creating A Website - Part 1: Web Design principles, HTML & CSS. CSS Color Values. Hexadecimal Colors. RGB Color

CSS: Formatting Text. CSS for text processing: font-family. Robert A. Fulkerson

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

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

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

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations).

Chapter 4 CSS basics

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

CSS: Cascading Style Sheets

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

CSS. Lecture 16 COMPSCI 111/111G SS 2018

HTML/XML. HTML Continued Introduction to CSS

Cascading Style Sheets (CSS)

ACSC 231 Internet Technologies

CSS Lecture 16 COMPSCI 111/111G SS 2018

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

CSS Selectors. element selectors. .class selectors. #id selectors

Admin. Midterm 1 on. Oct. 13 th (2 weeks from today) Coursework:

CSE 154 LECTURE 3: MORE CSS

Three Ways to Use CSS:

Chapter 12: FORMATTING TEXT

Web Site Design and Development Lecture 6

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Cascading Style Sheets Level 2

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

Introducing Cascading Style Sheets. Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS

CHAPTER 3 WEB DESIGN BASICS KEY CONCEPTS

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Using CSS in Web Site Design

Adding CSS to your HTML

Introduction to Web Tech and Programming

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

CSC 443: Web Programming

ITNP43: HTML Lecture 4

Zen Garden. CSS Zen Garden

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

EECS1012. Net-centric Introduction to Computing. Lecture 3: CSS for Styling

Cascading Style Sheets. Overview and Basic use of CSS

ASMP Website Design Specifications

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

CSc 337 LECTURE 3: CSS

CSS for Styling CS380

LECTURE 05 WEB DESIGN

The Benefits of CSS. Less work: Change look of the whole site with one edit

Tutorial 3: Working with Cascading Style Sheets

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

CSS FOUNDATIONS IN-DEPTH. The nitty-gritty of css...

DAY 4. Coding External Style Sheets

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

To link to an external stylesheet, the link element is placed within the head of the html page:

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

Introduction to WEB PROGRAMMING

Creating and Building Websites

How to create and edit a CSS rule

HIERARCHICAL ORGANIZATION

CS 350 Internet Applications I Name: Exam II (CSS) October 29, 2013

Cascade Stylesheets (CSS)

2005 WebGUI Users Conference

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

Block & Inline Elements

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

Styles, Style Sheets, the Box Model and Liquid Layout

Assignments (4) Assessment as per Schedule (2)

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

Style Sheet Reference Guide

Using Dreamweaver CS6

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

Networks and Web for Health Informatics (HINF 6220) Tutorial 8 : CSS. 8 Oct 2015

CSS: Cascading Style Sheets

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

2. Write style rules for how you d like certain elements to look.

Chapter 3 Style Sheets: CSS

CMPT 165: More CSS Basics

McMaster Brand Standard for Websites

WEB DESIGN: CONSTRUCTION, FILES, CODE AND COLOURS UNIT NUMBER: H383 34

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

Activity 4.1: Creating a new Cascading Style Sheet

Web Design and Development Tutorial 03

8a. Cascading Style Sheet

Transcription:

1

Web Development & Design Foundations with HTML5 CHAPTER 3 CSS BASICS Copyright Terry Felke-Morris 2

Learning Outcomes In this chapter, you will learn how to... Describe the evolution of style sheets from print media to the Web List advantages of using Cascading Style Sheets Use color on web pages Create style sheets that configure common color and text properties Apply inline styles Use embedded style sheets Use external style sheets Configure element, class, id, and contextual selectors Utilize the cascade in CSS Validate CSS 3

Overview of Cascading Style Sheets (CSS) See what is possible with CSS: Visit http://www.csszengarden.com Style Sheets used for years in Desktop Publishing apply typographical styles and spacing to printed media CSS provides the functionality of style sheets (and much more) for web developers a flexible, cross-platform, standards-based language developed by the W3C. 4

CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate document and associated with the web page Potentially smaller documents Easier site maintenance 5

Types of Cascading Style Sheets Inline Styles Embedded Styles External Styles Imported Styles 6

Inline Styles body section HTML style attribute apply only to the specific element Embedded Styles head section HTML style element apply to the entire web page document Cascading Style Sheets External Styles Separate text file with.css file extension Associate with a HTML link element in the head section of a web page Imported Styles Similar to External Styles We ll concentrate on the other three types of styles. 7

CSS Syntax Style sheets are composed of "Rules" that describe the styling to be applied. Each Rule contains a Selector and a Declaration 8

CSS Syntax Sample Configure a web page to display blue text and yellow background. body { color: blue; background-color: yellow; } This could also be written using hexadecimal color values as shown below. body { color: #0000FF; background-color: #FFFF00; } 9

Common Formatting CSS Properties See Table 3.1 Common CSS Properties, including: background-color color font-family font-size font-style font-weight line-height margin text-align text-decoration width 10

Using Color on Web Pages Computer monitors display color as intensities of red, green, and blue light RGB Color The values of red, green, and blue vary from 0 to 255. Hexadecimal numbers (base 16) represent these color values. 11

Hexadecimal Color Values # indicates a hexadecimal value Hex value pairs range from 00 to FF Three hex value pairs describe an RGB color #000000 black #FFFFFF white #FF0000 red #00FF00 green #0000FF blue #CCCCCC grey 12

Web Color Palette A collection of 216 colors Display the most similar on the Mac and PC platforms Hex values: 00, 33, 66, 99, CC, FF Color Chart http://webdevfoundations.net/color 13

Making Color Choices How to choose a color scheme? Monochromatic http://meyerweb.com/eric/tools/color-blend Choose from a photograph or other image http://www.colr.org Begin with a favorite color Use one of the sites below to choose other colors http://colorsontheweb.com/colorwizard.asp https://color.adobe.com/create/color-wheel http://paletton.com 14

Support Web Accessiblity Verify Sufficient Contrast When you choose colors for text and background, sufficient contrast is needed so that the text is easy to read. Use one of the following online tools to verify contrast: http://webaim.org/resources/contrastchecker http://snook.ca/technical/colour_contrast/colour.html http://juicystudio.com/services/luminositycontrastratio.php 15

Configuring Color with Inline CSS Inline CSS Configured in the body of the web page Use the style attribute of an HTML tag Apply only to the specific element The Style Attribute Value: one or more style declaration property and value pairs Example: configure red color text in an <h1> element: <h1 style="color:#ff0000">heading text is red</h1> Demo 16

Configuring Color with Inline CSS (2) Example 2: configure the red text in the heading configure a gray background in the heading Separate style rule declarations with ; Demo <h1 style="color:#ff0000;background-color:#cccccc">this is displayed as a red heading with gray background</h1> 17

CSS Embedded (Internal) Styles Configured in the head section of a web page. Use the HTML <style> element Apply to the entire web page document Style declarations are contained between the opening and closing <style> tags Example: Configure a web page with white text on a black background <style> body { background-color: #000000; color: #FFFFFF; } </style> 18

CSS Embedded Styles The body selector sets the global style rules for the entire page. <style> body { background-color: #E6E6FA; color: #191970;} h1 { background-color: #191970; color: #E6E6FA;} h2 { background-color: #AEAED4; color: #191970;} </style> These global rules are overridden for <h1> and <h2> elements by the h1 and h2 style rules. Demo 19

Configuring Text with CSS CSS properties for configuring text: font-weight Configures the boldness of text font-style Configures text to an italic style font-size Configures the size of the text font-family Configures the font typeface of the text Demo 20

The font-size Property Accessibility Recommendation: Use em or percentage font sizes these can be easily enlarged in all browsers by users 21

The font-family Property Not everyone has the same fonts installed in their computer Configure a list of fonts and include a generic family name p { font-family: Arial, Verdana, sans-serif; } 22

Embedded Styles Example <style> body { background-color: #E6E6FA; color: #191970; font-family: Arial, Verdana, sans-serif; } h1 { background-color: #191970; color: #E6E6FA; line-height: 200%; font-family: Georgia, "Times New Roman", serif; } h2 { background-color: #AEAED4; color: #191970; text-align: center; font-family: Georgia, "Times New Roman", serif; } p {font-size:.90em; text-indent: 3em; } ul {font-weight: bold; } </style> 23

More CSS TEXT Properties line-height Configures the height of the line of text (use the value 200% to appear double-spaced) text-align Configures alignment of text within a block display element text-indent Configures the indentation of the first line of text text-decoration Modifies the appearance of text with an underline, overline, or line-through text-transform Configures the capitalization of text letter-spacing Configures space between text characters word-spacing Configures space between words text-shadow Configures a drop shadow on text Demo 24

CSS style rules can be configured for an: HTML element selector class selector id selector descendant selector CSS Selectors 25

class Selector Apply a CSS rule to a certain "class" of elements on a web page Does not associate the style to a specific HTML element Using CSS with class Configure with.classname code CSS to create a class called new with red italic text. Apply the class: <style>.new { color: #FF0000; font-style: italic; } </style> <p class= new >This is text is red and in italics</p> Demo 26

Using CSS with id id Selector Apply a CSS rule to ONE element on a web page. Configure with #idname Code CSS to create an id called new with red, large, italic text. Apply the id: <style> #new { color: #FF0000; font-size:2em; font-style: italic; } </style> Demo <p id= new >This is text is red, large, and in italics</p> 27

CSS Descendant Selector Specify an element within the context of its container (parent) element. AKA contextual selector The example configures a green text color only for p tags located within an element assigned to the id named content Advantage of contextual selectors: Reduces the number of classes and ids you need to apply in the HTML Demo <style> #content p { color: #00ff00; } </style> 28

span element Purpose: configure a specially formatted area displayed inline with other elements, such as within a paragraph. There is no additional empty space above or below a span it is inline display. 29

span Element Example Embedded CSS: <style>.companyname { font-weight: bold; </style> HTML: font-family: Georgia, "Times New Roman", serif; font-size: 1.25em; } <p>your needs are important to us at <span class= companyname">acme Web Design</span>. We will work with you to build your Web site.</p> Demo 30

External Style Sheets - 1 CSS style rules are contained in a text file separate from the HTML documents. The External Style Sheet text file: extension ".css" contains only style rules does not contain any HTML tags 31

External Style Sheets - 2 Multiple web pages can associate with the same external style sheet file. site.css body {background-color:#e6e6fa; color:#000000; font-family: Arial, sans-serif; font-size:90%; } h2 { color: #003366; } nav { font-size: 16px; font-weight: bold; } index.html clients.html about.html Etc 32

link Element A self-contained tag Placed in the head section Purpose: associates the external style sheet file with the web page. Example: <link rel="stylesheet" href="color.css"> 33

Using an External Style Sheet External Style Sheet color.css body { background-color: #0000FF; color: #FFFFFF; } To associate the external style sheet called color.css, the HTML code placed in the head section is: <link rel="stylesheet" href="color.css"> 34

Centering Page Content with CSS #container { margin-left: auto; margin-right: auto; width:80%; } 35

The Cascade 36

http://jigsaw.w3.org/css-validator/ W3C CSS Validation 37