XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

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
Today CSS HTML A project.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
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.
Creating Special Effects with CSS
Tutorial 5 Working with the Box Model. XP Objectives Understand the box model Create padding, margins, and borders Wrap text around an image Float a block-level.
Working with Cascading Style Sheets
Chapter 7 Using Advanced Cascading Style Sheets HTML5 & CSS 7 th Edition.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 4 Creating Special Effects with CSS
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
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.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
The Characteristics of CSS
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.
Tutorial 4 Creating Special Effects with CSS
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
CSS – Presentation of Information. Types of Style Sheets External Embedded h1{color:red; font-family: Arial;} Inline Text is here.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
WRT235: Writing in Electronic Environments CSS Classes, IDs, divs.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
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.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
Introduction to CSS September 20, Introduction Cascading Style Sheets (CSS) –Separation of structure from presentation CSS guide and tutorial.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Positioning and Printing Creating Special Effects with CSS.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Maureen Smith Professor Tutorial 4.  Review  Session 4.1  Session 4.2  Session 4.3  Review.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 6.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
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.
Internet & World Wide Web How to Program, 5/e 1. 2.
CSS.
Working with Cascading Style Sheets
Cascading Style Sheets
>> CSS Rules Selection
Tutorial 3 Working with Cascading Style Sheets
Tutorial 4 Creating Special Effects with CSS
Presentation transcript:

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 2 Using Inline Styles Session 7.1 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;…”>

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 3 Using Embedded Styles You can embed style definitions in a document head using the following form: style declarations Where style declarations are the declarations of the different styles to be applied to the document.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 4 Using an External Style Sheet Because an embedded style sheet only applies to the content of the file it is embedded in, you need to place style declarations 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. –It can be linked to any page in the site, allowing the same style declaration to be applied to the entire site

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 5 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.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 6 Using an External Style Sheet You can import the content of one style sheet into another. Add the following to either an embedded or an external style sheet

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 7 Understanding Cascading Order You can link a single style sheet to multiple documents in your Web site by using the link element or element. You can also link a single document to several style sheets.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 8 Applying a single style sheet to multiple documents

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 9 Applying multiple sheets to a single document

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 10 Style Precedence 1.External style sheet 2.Embedded styles 3.Inline styles

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 11 Style Precedence If two styles have the same weight then the one declared last has precedence. H1 {color: orange; font-family: sans-serif”} H1{color: blue; font-family: serif}

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 12 Style Precedence You can override the precedence rules by adding the !important property to a style declaration H1 {color: orange !important; font-family: sans-serif”} H1{color: blue; font-family: serif} Gives the orange colour precedence

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 13 Style Inheritance If a style is not specified for an element, it inherits the style of its parent element. This is called style inheritance. –Causes style declarations to cascade down through a document’s hierarchy To set every element on a page to blue –Body {color: blue} Every element on the page inherits this style

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 14 Style Inheritance To override style inheritance you specify an alternate style for one of the descendent elements of the parent. –Body {color: blue} –P {color: red} –Changes every element on the page to blue except for paragraphs and every element within a paragraph !important property also overrides style inheritance

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 15 Working with Selectors CSS allows you to work with a wide variety of selectors to match different combinations of elements. –h1, h2, h3 {font-family: sans-serif} –h1 {color: blue} –h2 {color: red} h1 headings are blue sans-serif h2 headings are red sans-serif.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 16 Working with Selectors Set all bold text to blue –b {color: blue } Use contextual selectors to apply a style based on the context in which an element is used. Eg, to apply a style to text within a list –li b {color: blue} li is the parent element, b is the descendant element

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 17 Simple and contextual selectors

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 18 Attribute Selectors Create an attribute selector to select an element based on the element’s attributes. –a {color: blue} – all tags –a[href] {color: blue} – only hrefs, not anchors –See figure 7-13 in your text for a list of attribute selectors

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 19 Using IDs and Classes Session 7.2 Use an id to distinguish something, like a paragraph, from the others in a document. –For example, to identify a paragraph as “head”, use the code : …

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 20 Classes HTML and XHTML require each id be unique– therefore an id value can only be used once in a document. You can mark a group of elements with a common identifier using the class attribute. …

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 21 Applying a style to a class

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 22 Applying a style to a class and element

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 23 Sizing Elements and Floating an Element You can define the width of columns in a columnar layout using: width: value You can use CSS to set an element’s height using: height: value You can float a paragraph using: float: position

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 24 Working with the div Element The div element is a generic block-level element. content

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 25 Setting the Display Style Values of the display style

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 26 Setting the Display Style Values of the display style

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 27 Working with the Box Model The box model is an element composed of four sections: –Margin –Border –Padding –content

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 28 The Box Model

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 29 Working with the Box Model Styles to set padding are similar to styles to set margins: –padding-top: value –padding-right: value –padding-bottom: value –padding-left: value

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 30 Border Styles

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 31 Border Style Types

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 32 Using Pseudo-Classes and Pseudo-Elements A pseudo-class is a classification of an element based on its status, position, or current use in the document.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 33 Using Pseudo-Classes and Pseudo-Elements Rollover effects can be created using pseudo-classes. Pseudo-elements are elements based on information about an element’s content, use or position.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 34 Positioning Objects with CSS Session 7.3 The different positioning styles in the original CSS1 specifications were known as CSS- Positioning or CSS-P. To place an element at a specific position on a page use: position: type; top: value; right: value; bottom: value; left: value;

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 35 Working with Overflow and Clipping The overflow property syntax: overflow: type

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 36 Stacking Elements Specify stacking order with: z-index: value z-index: 3 z-index: 1 z-index: 2

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 37 Working with Different Media Specify output styles for particular devices in the media attribute of the link and style elements

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 38 Rule You can also specify the output media within a style sheet type {style declarations} Where media is one of the supported media types and style declarations are the styles associated with that media type.

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 39 Media Groups CSS2 uses media groups to describe basic facets of different media– and to differentiate between different types of media based on the ways they render content. –Continuous or paged –Visual, aural, or tactile –Grid (for character grid devices) or bitmap –Interactive or static

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 40 Media Groups

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 41 Hiding Elements Two different styles that allow you to hide elements: –Display style –Visibility style

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 42 Comparing the visibility and display styles Visibility hidden Object is hidden but still is part of the page flow Display: none Object is hidden and is removed from the page flow

XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 43 Using Print Styles You can specify the size of a page, margins, internal padding, etc. of the page box. Review the Reference Window on page HTML 420 for working with print styles.