MORE Cascading Style Sheets (The Positioning Model)

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

Introduction to HTML & CSS
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
Cascading Style Sheets CSS. What is it? Another file format ! its not like html Describes the looks of “selectors” in a.css file (example.css) in the.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
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.
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.
“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn.
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
INTRODUCTORY Tutorial 3 Using CSS to Format Multiple Pages.
AD Intermediate Computer Graphics | spring 2008 | Daria Tsoupikova | School of Art and Design | UIC CSS Cascading Style Sheets.
Cascading Style Sheets. Slide 2 Lecture Overview Overview of Cascading Style Sheets (CSS) Ways to declare a CSS CSS formatting capabilities New features.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
Cascading Style Sheets Controlling the Display Of Web Content.
Cascading Style Sheets Controlling the Display Of Web Content.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Cascading Style Sheets Dreamweaver. Styles Determine how the HTML code will display Determine how the HTML code will display Gives designers much more.
Review: Three parts to a webpage: - Content - Structure  XHTML - Presentation  CSS In this chapter we will focus on introducing and examining the mechanics.
Smashing ~ Chapter 2.  Why are they so important? ◦ Without them we would have no way of assigning styles to elements. ◦ By using selectors we can accomplish.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Using Styles and Style Sheets for Design
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheet (CSS)
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Doman’s Sections Information in this presentation includes text and images from
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Part 1: CSS - Why? - How it works - Writing rules - Examples.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Cascading Style Sheets CSS by Pavlovic Nenad by. 2Cascading Style Sheets Presentation Contents What are CSS? What are CSS? History of CSS History of CSS.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Working with Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 5.
Form Tag How to use Form Tag Something NEW ? PARAMETER Attribute NAME Specifies the name for a form To specify which form to submit with JavaScript, this.
IS 360 Declaring CSS Styles. Slide 2 Introduction Learn about the three ways to declare a style Inline / embedded / external Learn about the effect of.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
INTRODUCTORY Tutorial 3 Using CSS to Format Multiple Pages.
>> More on CSS Selectors. Pre-requisite Open the file called sample.txt Copy the all the text from the file Open your browser and go to codepen.io Paste.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Cascading Style Sheets CSS2 - a bit more advanced.
Relative, absolute, and Floating Positioning, Cascading Style Sheet, and Inheritance.
CSS: Cascading Style Sheets Part II. Style Syntax.
CH 12 CSS Style Sheets 1. Objective What is CSS? Selecting elements Different rules for different media Importing style sheets 2.
Tutorial 3 Designing a Web Page with CSS
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition.
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.
IS 360 Understanding CSS Selectors. Slide 2 Types of Selectors There are different types of selectors Each has a different level of “specificity” An element.
Internet & World Wide Web How to Program, 5/e 1. 2.
Getting Started with CSS
CSS: Cascading Style Sheets
IS 360 Declaring CSS Styles
>> CSS Rules Selection
CSS Intro.
Website Design 3
IS 360 Understanding CSS Selectors
Web Design and Development
Chapter 6 Introducing Cascading Style Sheets
Cascading Style Sheets
Presentation transcript:

MORE Cascading Style Sheets (The Positioning Model)

Slide 2 Introduction Attribute selectors Pseudo-elements Pseudo-classes How style rules are applied (the meaning of cascade)

Slide 3 Attribute Selectors (Introduction) In addition to element, class and ID selectors, it’s possible to select elements having a specific attribute defined a specific attribute value

Slide 4 The [attribute] selector Select elements with an attribute named [target] a[target] { font-size: 14pt; }

Slide 5 The [attribute=value] Selector Select elements with an attribute named [target] having a value of _blank a[target=“_blank”] { font-size: 14pt; }

Slide 6 The Universal Selector It selects all elements and children The * character is the universal selector Select all elements inside a element and set the background color

Slide 7 Pseudo-elements (Introduction) A pseudo-element is used to apply a style to part of an element For example, the first or last line of a paragraph The following syntax is used to apply a pseudo-element:

Slide 8 Pseudo-elements (List) ::after – Insert content after element p::after { content: " Append Text"; } ::before – Insert content before element p::before { content: " Preappend Text"; }

Slide 9 Pseudo-elements (List) ::first-letter – Selects first letter p::first-letter { font-size: 14pt; } ::first-line – Selects first line p::first-line { font-size: 14pt; }

Slide 10 Pseudo-classes (Introduction) Pseudo-classes define the special state of an element Mouse hover They are commonly used with anchor tags: Visited / non-visited links

Slide 11 Pseudo-classes (Anchor)

Slide 12 Pseudo-classes (List) The following W3Schools links lists all of the pseudo classes lasses.asp lasses.asp

Slide 13 What we Mean by Cascade The concept of cascade is tied to three concepts (rules) Importance Specificity Source order After these rules are applied, a weight is applied to each rule to determine which one takes precedence

Slide 14 Importance (1) Importance relates to the source of a style sheet User agent – browsers tend to have a default style User – You might have configured browser options to have a style Author – These are the inline / embedded / external styles that we have been talking about These sources are processed in order

Slide 15 Importance (2) The !important declaration overrides the default cascade so styles are applied in the following order 1. User agent declarations (browser) 2. User declarations 3. Author declarations 4. Author !important declarations 5. User !important declarations

Slide 16 Specificity (1) Every CSS rule has a weight That is, one rule might be more or less important than another, or equally important This weight can be precisely calculated There are different ways (techniques) to do this

Slide 17 Specificity (2) Add 1 for each element and pseudo-element Add 10 for each attribute, class, and pseudo- class Add 100 for each ID Add 1000 for an inline style

Slide 18 Specificity (3) p.note 1 class (10) + 1 element (1) = 11 #MyID p[lang=“en”] 1 ID (100) + 1 attribute (10) + 1 element (1) = 111 If two rules have the same specificity, then the last rule processed wins

Slide 19 Specificity (Guidelines) Use generic selectors first and add specificity as necessary Rely on specificity rather than ordering selectors Try and keep thing simple

Slide 20 Inheritance Inheritance is how property values propagate from parent elements to child elements For example, setting the font for a tag will cause the same font to be applied Not all properties are inherited Inheritance can be forced using the inherit keyword Note the CSS3 inheritance specifications are in “working draft” mode (not final)

Slide 21 Inheritance Don’t break it breaking-inheritance breaking-inheritance A canonical list of properties and those that inherit

Slide 22 Tools Firebug is an add-in for chrome that helps debug styles