Tutorial 3 Working with Cascading Style Sheets

Slides:



Advertisements
Similar presentations
Intro To Cascading Style Sheets By Mario Yannakakis.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Cascading Style Sheets
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.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
กระบวนวิชา 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.
Chapter 8 Creating Style Sheets.
Tutorial 3 – Designing a Web Page Working with Color & Graphics Mrs. Wilson.
Tutorial 3 Working with Cascading Style Sheets. XP Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
4.01 Cascading Style Sheets
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
1 Working with Cascading Style Sheet (CSS) (contd.)  What we will cover… 1. Color (decimal and hexadecimal representation) 2. Floating elements 3. Styling.
Tutorial 3 Working with Cascading Style Sheets (CSS)
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
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.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Tutorial 3 Designing a Web Page with CSS
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
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.
1 Cascading Style Sheets
Working with Cascading Style Sheets
CSS Cascading Style Sheets
CNIT 131 Graphics.
Getting Started with CSS
4.01 Cascading Style Sheets
Web Development & Design Foundations with HTML5 8th Edition
Introduction to CSS.
Cascading Style Sheets
Web Development & Design Foundations with HTML5
Introduction to the Internet
Chapter 6 Cascading Style Sheets™ (CSS)
Madam Hazwani binti Rahmat
>> CSS Rules Selection
CX Introduction to Web Programming
Web Developer & Design Foundations with XHTML
Using Cascading Style Sheets Module B: CSS Structure
Introduction to Web programming
Web Development & Design Foundations with HTML5
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
Cascading Style Sheets - Building a stylesheet
Introduction to CSS.
CSS Style Sheets: Intro
Stylin’ with CSS.
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™ (CSS)
Exercise 9 Skills You create and use styles to create formatting rules that can easily by applied to other pages in the Web site. You can create internal.
Introduction to CSS.
Cascading Style Sheets - Building a stylesheet
Stylin’ with CSS.
4.01 Cascading Style Sheets
Stylin’ with CSS.
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

Tutorial 3 Working with Cascading Style Sheets

Objectives Explore inline styles, embedded styles, and external style sheets Understand the CSS use of color Explore CSS styles for fonts and text Apply a background image to an element New Perspectives on HTML and XHTML, Comprehensive

Introducing Cascading Style Sheets Style sheets are declarations that describe the layout and appearance of a document Cascading Style Sheets (CSS) is a style sheet language used on the Web CSS specifications are maintained by the World Wide Web Consortium (W3C) Several versions of CSS exist: CSS1, CSS2, CSS 2.1, and CSS3 New Perspectives on HTML and XHTML, Comprehensive

Applying a Style Sheet Three ways to apply a style to an HTML or XHTML document: Inline Styles Embedded Style Sheet External Style Sheet New Perspectives on HTML and XHTML, Comprehensive

Using Inline Styles Inline styles are easy to use and interpret because they are applied directly to the elements they affect <element style=“style1: value1; style2: value2; style3: value3;…”> Example: < h1 style =“text-align: center; color:red”> Welcome </h1> New Perspectives on HTML and XHTML, Comprehensive

Using Embedded Styles You can embed style definitions in a document head using the following form: <style type=“text/css”> selector { style1: value1; style2: value2; style3:value3;..} … </style> Example: h1 {text-align: center; color:red} New Perspectives on HTML and XHTML, Comprehensive

Using Embedded Styles Example: <style type=“text/css”> h1,h2 {text-align: center; color:red} </style> New Perspectives on HTML and XHTML, Comprehensive

Using an External Style Sheet Because an embedded style sheet only applies to the content of one file, you need to place a style declaration in an external style sheet to apply to the rest of the Web site An external style sheet is a text file that contains style declarations and it is extension .css It can be linked to any page in the site, allowing the same style declaration to be applied to the entire site It is like a set of embedded styles but without opening and closing <style> tags. New Perspectives on HTML and XHTML, Comprehensive

Using an External Style Sheet You can add style comments as you develop an external style sheet /* comment */ Use the link element to link a Web page to an external style sheet and placed it in the head section. <link href=“url” rel=“stylesheet” type=“text/css” /> New Perspectives on HTML and XHTML, Comprehensive

New Perspectives on HTML and XHTML, Comprehensive

New Perspectives on HTML and XHTML, Comprehensive

Style Inheritance If a style is not specified for an element, it inherits the style of its parent element. This is called style inheritance Example 1: body {color: blue} Example 2: p {color: red} In the above example, the body element is the parent element New Perspectives on HTML and XHTML, Comprehensive

Applying a Style to a Specific ID To apply a style to an element marked with a specific id value, use the declaration #id {style rule} where id is the value of the element’s id attribute and style rule stands for the styles applied to that specific element <h2 id =“subtitle”>Welcome </h2> In your code, you can set the font color to red using the following style: #subtitle {color:red} New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS HTML is a text-based language, requiring you to define your colors in textual terms HTML identifies a color in one of two ways: By the color value By the color name To have more control and more choices, specify colors using color values A color value is a numerical expression that precisely describes a color New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS Any color can be thought of as a combination of three primary colors: red, green, and blue By varying the intensity of each primary color, you can create almost any color and any shade of color This principle allows a computer monitor to combine pixels of red, green, and blue to create the array of colors you see on your screen New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS Software programs, such as your Web browser, define color mathematically The intensity of each of three colors (RGB) is assigned a number from 0 (absence of color) to 255 (highest intensity) Each color is represented by a triplet of numbers, called an RGB triplet, based on the strength of its Red, Green, and Blue components rgb ( red, green, blue) New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS Examples: White rgb ( 255, 255, 255) Black rgb ( 0, 0, 0) Orange rgb(255, 165, 0) New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS HTML requires color values be entered as hexadecimals A hexadecimal is a number based on a base-16 numbering system rather than a base-10 numbering system that we use every day Once you know the RGB triplet of a color, the color needs to be converted to the hexadecimal format rgb(255,255,0) = #FFFF00 New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS Using the basic color names allows you to accurately display them across different browsers and operating systems The list of only 17 colors is limiting to Web designers New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS Partial list of extended color names New Perspectives on HTML and XHTML, Comprehensive

Working with Color in HTML and CSS h1 {text-align:center; color:rgb(255,255,0)} h2 {color:#808000} New Perspectives on HTML and XHTML, Comprehensive

Defining Text and Background Colors Background color definition: background-color: color Text color definition: color: color where color is either the color value or the color name You can apply text and background colors to any page element New Perspectives on HTML and XHTML, Comprehensive

New Perspectives on HTML and XHTML, Comprehensive

Working with Fonts and Text Styles A specific font is a font such as Times New Roman, Arial, or Garamond. The font is installed on a user’s computer A generic font refers to the font’s general appearance Generic fonts New Perspectives on HTML and XHTML, Comprehensive

Working with Fonts and Text Styles CSS allows you to specify a list of specific fonts along with a generic font font-family: fonts If the browser cannot find any of the specific fonts listed, it uses the generic font font-family: Arial, Helvetica, sans-serif New Perspectives on HTML and XHTML, Comprehensive

Applying Font Features text-decoration: type Where type is underline, overline, line-through, or blink p { text-decoration:underline overline} New Perspectives on HTML and XHTML, Comprehensive

Setting the Image Size By default, browsers display an image at its saved size You can specify a different size by adding the HTML attributes width="value" height="value" New Perspectives on HTML and XHTML, Comprehensive

Formatting Backgrounds The syntax for inserting a background image is: background-image: url(url) URL is the location and filename of the graphic file you want to use for the background of the Web page New Perspectives on HTML and XHTML, Comprehensive

New Perspectives on HTML and XHTML, Comprehensive

Background Image Options By default, background images are tiled both horizontally and vertically until the entire background of the element is filled up You can specify the direction of the tiling using the style: background-repeat: type New Perspectives on HTML and XHTML, Comprehensive

Background Image Options New Perspectives on HTML and XHTML, Comprehensive

New Perspectives on HTML and XHTML, Comprehensive

The Background Style background-attachment: type where type is either scroll or fixed body {background-image: url(wallpaper.jpg); background-repeat: no-repeat; background-attachment: fixed} New Perspectives on HTML and XHTML, Comprehensive