Working with Cascading Style Sheets

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.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
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.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Review CSS.
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 6 Creating Fixed-Width Layouts
Tutorial 3 Working with Cascading Style Sheets. XP Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external.
Cascading Style Sheets Controlling the Display Of Web Content.
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.
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.
Tutorial 4 Creating Special Effects with CSS
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
Tutorial 3 Working with Cascading Style Sheets (CSS)
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.
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.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Introduction to Cascading Style-sheets (CSS) Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 1.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
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.
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.
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.
XP Review 1 New Perspectives on JavaScript, Comprehensive1 Introducing HTML and XHTML Creating Web Pages with HTML.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 6.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
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.
CSS.
Chapter 6 - Cascading Style Sheets™ (CSS)
4.01 Cascading Style Sheets
CSS: Cascading Style Sheets
Cascading Style Sheets
Madam Hazwani binti Rahmat
Web Systems & Technologies
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
6 Layout.
Styles and the Box Model
For the World Wide Web Positioning Objects with CSS
DynamicHTML Cascading Style Sheet Internet Technology.
DynamicHTML Cascading Style Sheet Internet Technology.
Tutorial 3 Working with Cascading Style Sheets
Tutorial 4 Creating Special Effects with CSS
Chapter 6 Introducing Cascading Style Sheets
Web Design & Development
4.01 Cascading Style Sheets
Presentation transcript:

Working with Cascading Style Sheets Tutorial 7 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

New Perspectives on HTML, XHTML, and DHTML, Comprehensive Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style Sheet Understanding Cascading Order Working with Selectors Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

New Perspectives on HTML, XHTML, and DHTML, Comprehensive Objectives Using IDs and Classes Sizing Elements Floating an Element Working with the div Element Setting the Display Style Working with the Box Model Using Pseudo-Classes and Pseudo-Elements Applying a Style to a Web Site Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

New Perspectives on HTML, XHTML, and DHTML, Comprehensive Objectives Positioning Objects with CSS Working with Overflow and Clipping Stacking Elements Working with Different Media Hiding Elements Using Print Styles Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

Cascading Style Sheets CSS1 introduced styles for the following document features: Fonts Text Color Backgrounds Block-level Elements Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

Cascading Style Sheets CSS2 introduced styles for the following document features: Positioning Visual Formatting Media Types Interfaces Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

Cascading Style Sheets CSS3 (which is still in development) will introduce styles for the following document features: User Interfaces Accessibility Columnar layout International Features Mobile Devices Scalable Vector Graphics Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

New Perspectives on HTML, XHTML, and DHTML, 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;…”> Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

Using an External Style Sheet Because an embedded style sheet only applies to the content of the start.htm file, you need to place a style declaration in an external style sheet to apply to the headings in 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 Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

Using an External Style Sheet You can add style comments as you develop an external style sheet Use the link element to link a Web page to an external style sheet You can import the content of one style sheet into another Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

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

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

New Perspectives on HTML, XHTML, and DHTML, Comprehensive Style Precedence External style sheet Embedded styles Inline styles Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

Working with Selectors CSS allows you to work with a wide variety of selectors to match different combinations of elements Use contextual selectors to apply a style based on the context in which an element is used Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

New Perspectives on HTML, XHTML, and DHTML, Comprehensive Attribute Selectors Create an attribute selector to select an element based on the element’s attributes See figure 7-13 in your text for a list of attribute selectors Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

New Perspectives on HTML, XHTML, and DHTML, Comprehensive Using IDs and Classes 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: <p id=“head”>… </p> Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

New Perspectives on HTML, XHTML, and DHTML, Comprehensive 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 <element class=“class”> … </element> Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

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

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

Working with the div Element The div element is a generic block-level element <div> content </div> Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

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

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

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

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

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

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

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

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

Positioning Objects with CSS 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; Tutorial 7 New Perspectives on HTML, XHTML, and DHTML, Comprehensive

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

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

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

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

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

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

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

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

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