CSS: Beyond the Code. Karen Perone Rodman Public Library.

Similar documents
Styles, Style Sheets, the Box Model and Liquid Layout

Cascading Style Sheets Level 2

Cascading Style Sheets (CSS)

CSS.

Assignments (4) Assessment as per Schedule (2)

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

CSS Selectors. element selectors. .class selectors. #id selectors

Zen Garden. CSS Zen Garden

Chapter 3 Style Sheets: CSS

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

CSS Cont'd: Cascading Style Sheets

Deccansoft Software Services

Introduction to WEB PROGRAMMING

COMP519 Web Programming Lecture 6: Cascading Style Sheets: Part 2 Handouts

INTRODUCTION TO HTML5! CSS Styles!

Client-Side Web Technologies. CSS Part I

CSS: The Basics CISC 282 September 20, 2014

2. Write style rules for how you d like certain elements to look.

To Ponder. Which one wins? .draft div.warning li { }.draft div #main li {!important; } div #main ul li { }.draft.warning ul li { }

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Web Engineering CSS. By Assistant Prof Malik M Ali

Web Design and Development Tutorial 03

BIM222 Internet Programming

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

CITS3403 Agile Web Development 2019 Semester 1

CSS worksheet. JMC 105 Drake University

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Web Site Design and Development Lecture 5

Certified CSS Designer VS-1028

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

CSS

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

Cascading Style Sheets CSCI 311

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

Website Development with HTML5, CSS and Bootstrap

HTML and CSS COURSE SYLLABUS

Cascading Style Sheet

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

Cascading Style Sheets

CSS Cascading Style Sheets

APPLIED COMPUTING 1P01 Fluency with Technology

Data Visualization (CIS/DSC 468)

CPET 499/ITC 250 Web Systems. Topics

Networks and Web for Health Informatics (HINF 6220) Tutorial 8 : CSS. 8 Oct 2015

Creating and Building Websites

2005 WebGUI Users Conference

CSC309 Winter Lecture 2. Larry Zhang

Web Information System Design No.4 Put Style to Web Documents. Tatsuya Hagino

Module 2 (VII): CSS [Part 4]

The Benefits of CSS. Less work: Change look of the whole site with one edit

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

Guidelines for doing the short exercises

CSS: Cascading Style Sheets

CSC309 Programming on the Web week 3: css, rwd

What is the Box Model?

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

the missing manual0 O'REILLY Third Edition David Sawyer McFarland Beijing Cambridge The book that should have been in the box Farnham

CSS: Cascading Style Sheets

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

CSS. Shan-Hung Wu CS, NTHU

ICT IGCSE Practical Revision Presentation Web Authoring

Symbols INDEX. !important rule, rule, , 146, , rule,

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

CSS Design and Layout Basic Exercise instructions. Today's exercises. Part 1: Arrange Page into Sections. Part 1, details (screenshot below)

Parashar Technologies HTML Lecture Notes-4

Adding CSS to your HTML

Data Visualization (DSC 530/CIS )

Block & Inline Elements

HTML and CSS a further introduction

Introduction to Computer Science Web Development

INTRODUCTION TO CSS. Topics MODULE 5

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

First Name Last Name CS-081 March 23, 2010 Midterm Exam

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

Lab Introduction to Cascading Style Sheets

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

COMP519 Web Programming Lecture 7: Cascading Style Sheets: Part 3 Handouts

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Appendix D CSS Properties and Values

Introduction to Computer Science Web Development

HTMLnotesS15.notebook. January 25, 2015

Html basics Course Outline

CITS3403 Agile Web Development 2018, Semester 1

This tutorial will help both students as well as professionals who want to make their websites or personal blogs more attractive.

Proper_Name Final Exam December 21, 2005 CS-081/Vickery Page 1 of 4

CSS. Location, Inheritance & the Cascade. Copyright DevelopIntelligence LLC

Lesson 5 Introduction to Cascading Style Sheets

Fundamentals of Web Technologies. Agenda: CSS Layout (Box Model) CSS Layout: Box Model. All HTML elements can be considered as a box or a container

Cascading Style Sheets (CSS)

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

CMPT 165 Advanced XHTML & CSS Part 3

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo

Transcription:

CSS: Beyond the Code Karen Perone Rodman Public Library peroneka@oplin.org

HTML vs. CSS vs. Javascript HTML for content (text, images, sound) CSS for presentation (layout, color) Javascript for behavior (cursor in the box, form field validation)

Why CSS? Keep presentation separate from the content Leaner, meaner web pages Ease of maintenance Easier means of reusing web pages for other purposes (RSS, text-to-speech) Separate style sheets for media types

The Cascade The C in CSS Least specific to most specific Depends on type of origin User agent (browser defaults) Author (web page creator) User (user styles in browser)

User Agent http://whatsmyuseragent.com/ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-us; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16 Built-in style sheet in all web browsers Varies from Firefox to IE6 to IE7 to Opera, etc.

Author Styles Created by the web site/page author Can be (least specific to most specific): Linked (external) Style element (embedded) Element attribute (in-line)

WebPAC Style Sheets ProStyles.css -or- iiistyles.css (default values; cannot be modified) styles.css (main author style sheet) ie_styles.css (specifically for IE browsers) printver.css (specifically for print version)

The Document Tree Helpful in determining containing elements Establishes: Ancestor Descendent Parent Child Sibling Determines inheritance of CSS rules

http://www.guistuff.com/css/css_doctree.html

Relationships http://www.guistuff.com/css/css_doctree.html

Class vs. ID ID Can be used only once on a page Identifies a specific section Example: toplogo, content, side navigation, footer Use in style sheet: div#nav Use in HTML: <div id= nav >

ID in styles.css Selector specified div#main {margin: 0 20px 5px 5%;} Implied universal selector #main div {padding-top:.2em} Can be combined with class #main.tabs a:hover { text-decoration: underline; }

Class vs. ID Class Can be used multiple times Styles a type of content Example: boldface, paragraph alignment, font Use in style sheet: p.bold Use in HTML: <p class= bold >

Class in styles.css Implied universal selector used extensively.navigationrow { margin: -3px; } Could be used as a div or p or ul div class= navigationrow p class= navigationrow ul class= navigationrow

Pseudo-classes Most common :link :visited :hover :active Always use in this order: L V H A (LoVe HA!)

Pseudo-classes Less often used :focus input:focus { background-color: Red; } BEFORE AFTER

Fun with Pseudo-classes :first-child table.bibitems tr.bibitemsentry td:first-child { font-weight: bold ; color: Green ; font-size: 200% ; background-color: red ; }

How We Got There From briefcit.html: table.bibitems tr.bibitemsentry td:first-child... span class="briefcititems" table class="bibitems" tbody tr class="bibitemsheader" tr class="bibitemsentry" th class="bibitemsheader" th class="bibitemsheader" th class="bibitemsheader" td td td a a

Specificity Represented by four comma-separated values Calculated based on counting elements in the selector The highest value wins In case of a tie, the last declaration wins

Figuring the Specificity 1. In-line style 2. Ids 3. Classes, Attributes, and Pseudo-classes 4. Element Types and Pseudo-elements

Consider This Example <style type= text/css > </style> p { color: black; background-color: blue; font-size: 3em; } div.warning p { color: red; } div#caution p { color: yellow; } body#home div p { color: white; } <body id="home"> <div id="caution"> <p>what color am I?</p> </div> </body> What color will the paragraph text be?

Add Up the Scores p { color: black; background-color: blue; font-size: 3em; } 0,0,0,1 div.warning p { color: red; } 0,0,1,2 div#caution p { color: yellow; } 0,1,0,2 body#home div p { color: white; } 0,1,0,3 <body id="home"> <div id="caution"> <p>what color am I?</p> </div> </body>

And the Winner Is

Inheritance of Style In the absence of a specific declaration for the element Value of element will inherit its characteristics from its parent

Specificity High to Low

Why Is My Text So Small? Container size has nothing to do with it Size property is inherited from parent Nesting the elements will cause cumulative size Relative font size the culprit

Container Elements Box elements that can contain other elements Examples of box elements: body div p h1 ul

Example div.a { font-size: 85% ; } div.b { font-size: 85% ; } div.c { font-size: 85% ; } <div class= a > text in div.a <div class= b > text in div.b <div class= c > text in div.c </div> </div> </div>

Hard to tell from here why text gets smaller

But add in borders and widths and it becomes apparent

Mathematically Speaking div.a - 85% of body default font size 85% x 100% = 85% div.b - 85% of div.a font size 85% x 85% = 72.25% div.c - 85% of div.b font size 85% x 72.25% = 61.41%

Options that Work div.a { font-size: 18pt ; width: 85% ; border: 2px solid red ;} div.b { font-size: 18pt ; width: 85% ; border: 2px dashed blue ;} div.c { font-size: 18pt ; width: 85% ; border: 2px dotted green ; } ================== div.a { font-size: 85% ; width: 85% ; border: 2px solid red ;} div.b { font-size: 1em ; width: 85% ; border: 2px dashed blue ;} div.c { font-size: 1em ; width: 85% ; border: 2px dotted green ; }

Check Your Work HTML Validator http://validator.w3.org/ CSS Validator http://jigsaw.w3.org/css-validator/

Check in Various Browsers http://browsershots.org/

CSS Editor TopStyle Lite or Pro http://www.bradsoft.com/topstyle/tslite/ Lite is free Pro is $79.95 and WORTH it

Develop Your Skills Take an Online Course http://eclasses.org/ Discounts available to International Webmasters Association members ($49 annually) http://www.iwanet.org/ http://www.w3schools.com/css/ (free)

For More Information General CSS: Olsson, Tommy & Paul O Brien. The Ultimate CSS Reference. Sitepoint, 2008. http://reference.sitepoint.com/css Specificity: O Brien, Paul. Get Specific with Your CSS Styles. www.sitepoint.com/article/getspecific-css-styles/

CSS Cookbooks Andrew, Rachel. The CSS Anthology: 101 Essential Tips, Tricks & Hacks. Sitepoint, 2007. Schmitt, Christopher. CSS Cookbook. O Reilly, 2007.