Cascading Style Sheets. Presented By Randal Rust July 17, 2002 r2communications.com randmich@hotmail.com. Agenda. What is CSS? Adding Styles to Your Page Basic Structure Inheritance & the Cascade Elements and Boxes Using CSS for Layout XHTML Organizing a Style Sheet Validation
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
F I N
Plus de contenu associé
Transcription de la présentation
Cascading Style Sheets Presented By Randal Rust July 17, 2002 r2communications.com randmich@hotmail.com
Agenda • What is CSS? • Adding Styles to Your Page • Basic Structure • Inheritance & the Cascade • Elements and Boxes • Using CSS for Layout • XHTML • Organizing a Style Sheet • Validation • CSS Examples
What Is CSS? • Cascading Style Sheets • Controls the presentation of HTML elements, including size, placement, color and font • Intended to replace table-based layouts, frames and other presentational hacks
What is CSS? • CSS is the W3C Standard for controlling the visual presentation of web pages • Essentially a set of page-layout tools • Intended to give the designer control over the display of the page, similar to what they have in InDesign or Quark Xpress
Benefits of CSS • Conserve bandwidth • Reduce development time and maintenance • Increased accessibility • Conformance to Section 508 and WCAG 1.0 • More sophisticated, cleaner appearance • Increased readability of documents • Easier to prepare content for delivery on multiple media devices
CSS Drawbacks • Not fully supported by NN 4 • Netscape 4 has little support for most of CSS 1 • Broken box model in IE 5 • Width and height of a box is incorrectly calculated • Fixed in IE 6 • Incomplete implementation of CSS 2 in all browsers • This is a minor issue
What is the W3C? • W3C founded by Tim Berners-Lee, who developed HTTP, addressing, URL and HTML • Industry consortium with more than 500 members • Develops technical standards for the web
What is a W3C Standard? • Finished specifications are called “Recommendations” • Members are supposed to implement them in their software • Intended to promote interoperability among different software and universal accessibility
Why Should You Care? • W3C recommendations are the foundation of Web’s future • Following standards promotes accessibility, usability and reduces maintenance
Rules • A style sheet contains “rules” that tell the browser how do display the elements on a Web page • A Rule is made up of a Selector and a Declaration • The Declaration contains a Property and a Value p { color: #000; } Selector Rule Declaration
Multiple Style Sheets • In the presence of multiple style sheets, the user agent must determine which rule has the most specificity • Style precedence is determined in three ways: • Inheritance • Specificity Calculations (skipping this) • The Cascade
Inheritance • Relies on parent>child relationships • Generally, Child Elements inherit styles from Parent Elements
The Cascade Example: p.instructions • Find all declarations that contain a matching selector • Sort by weight and origin (user agent, user, author) • User Agent>Author>User • Sort by specificity • Elements with higher specificity have more weight • Sort by order • The later a declaration appears in the style sheet or document, the more weight it is given • Imported/Linked>Embedded>Inline>User
Types of Elements • Block-Level • Generally items which are displayed on a line by themselves • p, h1-h6, ul, ol, table, div, body • Inline • These elements do not force a line break in the visual display • a, em, span, images, form inputs • List-Item • Elements that include the <li> element • Specially defined to have a marker (bullet, letter or number)
The Box Model • The most important part of CSS, if you are going to use CSS for layout • All Elements generate a box (Element Box) • The Element Box tells the browser how much space an element and its properties occupy
Box Components • Content • Set with the WIDTH and HEIGHT properties • Padding • Set with the PADDING property • Border • Set with BORDER property • Margin • Set with MARGIN property
The Importance of Boxes • Understanding the CSS Box Model is the most critical factor in using CSS for layout • Any version of IE before 6 renders boxes incorrectly
The Basics • Sketch out your page • Each area becomes a “containing box” • Give each box a unique name • This unique name will correspond to an ID Rule in your style sheet • Use inheritance and the cascade to minimize how many rules are in your style sheet