University of California  Irvine Advanced CSS: Beyond Simple Classes Katya Sadovsky

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties-- List properties –Table properties-- Classification properties.
Advertisements

LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.
Copenhagen, 6 December 2004 Modern CSS Principles Miruna Bădescu Finsiel Romania.
Table, List, Blocks, Inline Style
Table (TABLE) Contains TABLE ROWS (TR) Contains TABLE DATA (TD) Data can contain anything Text Lists Other tables Pictures …
Cascading Style Sheets (CSS)
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS Internet Engineering Spring 2014 Bahador Bakhshi CE & IT Department, Amirkabir University of Technology.
Cascading Style Sheets
Cascading Style Sheets
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
CSS: Separating Design and Content Kevin Campbell Katya Sadovsky.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
CSS. Intro to CSS Cascading Style Sheets – styles and enhances appearance of webpage.css extension.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
NSWI142 – Web Applications Lecture 3 – CSS (Part 1) Martin Nečaský, Ph.D. Web Applications (NSWI142 ), Lecture 31.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
Today’s objectives  Element relations – tree structure  Pseudo classes  Pseudo elements.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
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.
Using CSS (Cascading Style Sheets) Effie Nadiv Edited by permission from author by Amir Kirsh.
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.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
ADVANCED CSS William Neely CEO, Piecewise.com. CSS FONTS AND TEXT CSS ‣ Line-height allows to indicate the amount of space between lines; allows for equal.
CSS Statements, media queries, selectors, cascading Web Applications Martin Nečaský Department of Software Engineering, Faculty of Mathematics and Physics,
Cascading style sheets CSS
AD Intermediate Computer Graphics | spring 2008 | Daria Tsoupikova | School of Art and Design | UIC CSS Cascading Style Sheets.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
MORE Cascading Style Sheets (The Positioning Model)
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.
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.
การจัดรูปแบบเว็บด้วย CSS การเขียนโปรแกรมเว็บ. Selectors & cascading PatternMeaning *Universal selector: matches any element. EType selector: matches any.
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Neal Stublen Course Road Map  Create web page layouts using CSS  Manage CSS  Test website validity  Create navigation menus using.
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.
Advanced Cascading Style Sheets (CSS) Lecture # July 2013.
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.
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 (CSS) Part II IT210: Web-based IT.
Relative, absolute, and Floating Positioning, Cascading Style Sheet, and Inheritance.
CSS: Cascading Style Sheets Part II. Style Syntax.
Advanced CSS. Display  Hiding an element can be done in two ways  display:none  Element is hidden and will no longer take up space on the page  Can.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Working with Cascading Style Sheets
CSS: Cascading Style Sheets
Cao Yuewen SEEM4570 Tutorial 03: CSS Cao Yuewen
IS 360 Declaring CSS Styles
Chapter 3 Style Sheets: CSS
Web Systems & Technologies
The Internet 10/25/11 XHTML Tables
MORE Cascading Style Sheets (The Positioning Model)
IS 360 Understanding CSS Selectors
Cascading Style Sheets
Cascading Style Sheets
Web Development & Design Foundations with H T M L 5
Tutorial 4 Creating Special Effects with CSS
HTML / CSS Mai Moustafa Senior Web Designer eSpace eSpace.
The Internet 10/20/11 CSS Layout
Presentation transcript:

University of California  Irvine Advanced CSS: Beyond Simple Classes Katya Sadovsky

University of California  Irvine University of California, Irvine Located in Southern California Year Founded: 1965 Enrollment: over 24K students 1,400 Faculty (Academic Senate) 8,300 Staff 6,000 degrees awarded annually Carnegie Classification: Doctoral/Research – Extensive Extramural Funding - 311M in Undergoing significant enrollment growth

University of California  Irvine Agenda Brief overview of the Cascading Style Sheets (CSS) 2 syntax Selectors & cascading Block vs Inline elements CSS box model Element presentation: float, position, etc. Generated content Tips and tricks

University of California  Irvine What is CSS Cascading Style Sheets, or CSS, are a series of instructions that specify how markup elements should appear on a Web page. For the purposes of this presentation, I will focus on CSS level 2 specification.

University of California  Irvine The Sad Truth About IE Internet Explorer (even IE7) is still not CSS compliant Some of the areas not supported: –Child selectors –Attribute selectors –Counters

University of California  Irvine Brief overview of the CSS2 syntax Ruleset syntax : selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S* S* = [ \t\r\n\f]+ declaration = property ':' S* value; Example:. uportal-text-small { color : Black; font-family : Verdana, Geneva, Arial, Helvetica; font-size : 10px; } selector declaration property

University of California  Irvine Selectors & cascading Selectors are a way to match styles to elements in the document tree Different types of selectors: –Universal selector –Type selectors –Descendant selectors –Child selectors –Adjacent sibling selectors –Attribute selectors –ID selectors –Pseudo-elements –Pseudo-classes Spaces matter! –P#myid – selects a P element with id equal to “myid” –P #myid – selects an element with id equal to “myid” that is a descendant of P

University of California  Irvine Selectors & cascading PatternMeaning *Universal selector: matches any element. EType selector: matches any E element (i.e., an element of type E; e.g. H1 or P). E FDescendant selector: matches any F element that is a descendant of an E element. E > FChild selector: matches any F element that is a child of an element E. E + FAdjacent siblings selector: Matches any F element immediately preceded by an element E. E[foo]Attribute selector: matches any E element with the "foo" attribute set (whatever the value). E[foo="warning"]Attribute selector: matches any E element whose "foo" attribute value is exactly equal to "warning". E[foo~="warning"] Attribute selector: matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning". E[lang|="en"] Attribute selector: matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en“ (e.g. en-US). DIV.warningHTML only. The same as DIV[class~="warning"]. E#myidID selector: matches any E element ID equal to "myid". E:lang(c) Pseudo-class selector: matches element of type E if it is in (human) language c (the document language specifies how language is determined). E:first-childPseudo-class selector: matches element E when E is the first child of its parent. E:link, E:visited Pseudo-class selector: matches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited). E:active, E:hover, E:focusDynamic Pseudo-class selector: matches E during certain user actions. E:first-line, E:first-letterPseudo-element selector: matches the first formatted line or letter of element E. Works in most browsers (incl. IE)

University of California  Irvine Cascading and Inheritance When there are multiple rules that could apply to the same element and/or property and media type, sort declarations on (): 1.Weight (normal, !important) and origin (author, user, user agent) normal: author -> user -> user agent !important: user -> author -> user agent NOTE: user agents supply a “default” style sheet 2.Selector specificity: more specific selectors have precedence 3.Order specified: styles specified later in the order have precedence

University of California  Irvine Cascading and Inheritance STYLE attribute blockLinked stylesheetImported stylesheet overrides A simplified view of the preceding “formula”:

University of California  Irvine Logical vs Physical Tags “Logical” tags convey the structure and semantic information of the document (H1-H6, P, STRONG) “Physical” tags specify the visual presentation of document elements but do not convey the meaning of the document or its parts (B, U, FONT, BR) Do not use physical tags to solely describe the visual presentation of content (be mindful of alternative user agents such as speech readers or text-only browsers)

University of California  Irvine Block vs Inline elements Block-level elements are presented visually as blocks; i.e. they generate a line break before and after themselves (,, etc) –Can contain other block-level and inline elements –Act as containing blocks for nested elements All other elements, are inline elements; no line breaks are generated before and after ( ) –Cannot contain other block-level elements “Replaced” elements are those that are replaced by the content they point to (,, etc)

University of California  Irvine CSS box model content padding margin border Also, see 3D diagram at

University of California  Irvine Containing & Anonymous block boxes Block boxes can serve as containing blocks for child boxes –Note: if a block box has another block box inside it, then they are forced to have only block boxes inside it, by wrapping any inline boxes in an anonymous block box some text paragraph other text

University of California  Irvine Notes on boxes There are cases when adjacent margins collapse Relative positioning is calculated with respect to the content edge

University of California  Irvine Positioning schemes Positioning schemes in CSS include: –Normal flow (includes relative positioning) –Floating –Absolute positioning

University of California  Irvine Floating float property allows element boxes to be shifted to the right or left on the current line –Floated boxes are block boxes –Floated boxes are “pulled out” of the normal flow and repositioned –Must have explicit width –May overlap other boxes clear property specifies which side(s) of an element should NOT be adjacent to a floating box that is specified earlier in the document

University of California  Irvine Relative and Absolute Positioning position property: –static – box is positioned according to normal flow –relative – box is positioned relative to where it would have been placed in the normal flow –absolute – box is positioned relative to its containing block; these boxes are taken out of flow –fixed – box is fixed in relation to the viewport (a browser window or a printed page)

University of California  Irvine Element presentation display property controls what type of box is generated for an element –Values: inline | block | list-item | run-in | compact | marker | table | inline-table | table-row-group | table-header- group | table-footer-group | table-row | table-column- group | table-column | table-cell | table-caption | none | inherit

University of California  Irvine Generated content CSS allows authors to generate content that is not part of the document tree using the following entities: –:before pseudo-element –:after pseudo-element –content property

University of California  Irvine Tips and tricks Trick for extending a DIV over floating child divs: –IE: div.main { height: 100%; … } –Firefox: div.main:after { content: ""; display: block; height: 0; clear: both; visibility: hidden; }

University of California  Irvine Useful URLs CSS resources: – – – – – – – – –