Web Development & Design Foundations with XHTML

Slides:



Advertisements
Similar presentations
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Web Development & Design Foundations with XHTML Chapter 3 Key Concepts.
Cascading Style Sheets
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
CSS Cascading Style Sheets Cascading Style Sheets 1.
Today CSS HTML A project.
Introduction to CSS.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Web Development & Design Foundations with XHTML Chapter 3 Key Concepts.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Web Developer Foundations: Using XHTML Chapter 9 Cascading Style Sheet Concepts.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Cascading Style Sheets
CSS Cascading Style Sheets. CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate.
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
WebD Introduction to CSS By Manik Rastogi.
CSS Cascading Style Sheets.
Style Sheets.
Cascading style sheets basics
4.01 Cascading Style Sheets
Web Development & Design Foundations with HTML5 8th Edition
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Cascading Style Sheets
Web Development & Design Foundations with HTML5
Introduction to the Internet
Chapter 6 Cascading Style Sheets™ (CSS)
Madam Hazwani binti Rahmat
CX Introduction to Web Programming
Web Developer & Design Foundations with XHTML
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Introduction to Web programming
Copyright (c) 2007 Prentice-Hall. All rights reserved.
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheet (CSS)
Web Development & Design Foundations with HTML5
School of Business Administration
Introduction to CSS.
Intro to CSS CS 1150 Spring 2017.
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Stylin’ with CSS.
Web Development & Design Foundations with H T M L 5
Introduction to Cascading Style Sheets (CSS)
Web Programming– UFCFB Lecture 11
Working with Cascading Style Sheets (CSS)
Working with Cascading Style Sheets (CSS)
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets
Web Development & Design Foundations with H T M L 5
Web Development & Design Foundations with H T M L 5
Tutorial 3 Working with Cascading Style Sheets
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2016 Terry Ann Morris, Ed.D.
Cascading Style Sheets
Stylin’ with CSS.
4.01 Cascading Style Sheets
External Style Sheets.
Stylin’ with CSS.
CS332A Advanced HTML Programming
Presentation transcript:

Web Development & Design Foundations with XHTML Chapter 3 Styles

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 Exact same page, different styles

CSS Advantages Better page layout control (HTML doesn’t have much) Style is separate from structure Use the same style on many pages (Styles can be stored in a separate document and used on many pages for a consistent look) Smaller pages (if the style is stored separately) Easier site maintenance (Change in 1 place – update the whole site)

Types of Cascading Style Sheets Inline Styles In the body of the Web page Describe style in an XHTML tag Apply only to the specific element Embedded Styles In the header section of a Web page. Use the XHTML <style> element Apply to the entire Web page document External Styles In a separate text file with .css file extension The XHTML <link /> element in the header section of a Web page associates it with the .css file .

CSS Syntax Each Rule contains a Selector and a Declaration Selector = what are you selecting? Declaration = How do you want it to look?

CSS Syntax Sample blue words and a 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; }

Configuring Color with Inline CSS (1) What is the selector? What is the property being changed? What is the value it’s being changed to? Example: configure red color text in an <h1> element: <h1 style="color:#ff0000">Heading text is red</h1>

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

CSS Embedded Styles Configured in the header section of a Web page. Use the XHTML <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 type ="text/css"> body { background-color: #000000; color: #FFFFFF; } </style>

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

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

The font-size Property Point size is 72/inch used by printers Pixel size depends on the screen resolution Accessibility Recommendation: Use em or percentage font sizes – these can be easily enlarged in all browsers by users

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;}

Embedded Styles Example <style type="text/css"> 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; font-family: Georgia, "Times New Roman", serif; } p {font-size: .90em; } ul {font-weight: bold; } </style>

CSS Selectors CSS style rules can be configured for an: HTML element class Id By using the right selector

Using CSS with “class” class Selector Configure with .classname dot class Selector Use to apply a CSS rule to a certain "class" of elements on a Web page Does not associate the style to a particular XHTML element Configure with .classname The sample creates a class called “new” with red italic text. To use the class, code the following XHTML: <p class=“new”>This is text is red and in italics</p> <style type="text/css"> .new { color: #FF0000; font-style: italic; } </style>

Using CSS with “id” pound id Selector <style type="text/css"> One of a kind Configure with #idname The sample creates an id called “new” with red, large, italic text. To use the id, code the following XHTML: <p id=“new”>This is text is red, large, and in italics</p> <style type="text/css"> #new { color: #FF0000; font-size:2em; font-style: italic; } </style>

XHTML <div> and <span> elements If you want to mark up a section of a page to have a special look, use <div> Useful to define an that will contain other block-level tags (such as paragraphs or spans) within it. Div creates a line break before and after the section If you want to choose a subsection (like a few words in a paragraph or a few items in a list) use <span> to mark them There is no line break before and after the span.

XHTML <div> Element Example Configure a page footer area Embedded CSS: <style type="text/css"> .footer { font-size: small; text-align: center; } </style> XHTML: <div class=“footer">Copyright © 2009</div>

XHTML <span> Element Example Embedded CSS: <style type="text/css"> .companyname { font-weight: bold; font-family: Georgia, "Times New Roman", serif; font-size: 1.25em; } </style> XHTML: <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>

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

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

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

Using an External Style Sheet External Style Sheet color.css body { background-color: #0000FF; color: #FFFFFF; } To link to the external style sheet called color.css, the XHTML code placed in the header section is: <link rel="stylesheet" href="color.css" type="text/css" />

Checkpoint 3.2 1. Describe a reason to use embedded styles. Explain where embedded styles are placed on a web page. 2. Describe a reason to use external styles. Explain where external styles are placed and how web pages indicate they are using external styles.