CSS: Cascading Style Sheets

Similar documents
CSS: The Basics CISC 282 September 20, 2014

CSS.

Assignments (4) Assessment as per Schedule (2)

CSS Cascading Style Sheets

To link to an external stylesheet, the link element is placed within the head of the html page:

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

Introduction to WEB PROGRAMMING

COMS 359: Interactive Media

Cascading Style Sheets CSCI 311

Cascading Style Sheets Level 2

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

In the early days of the Web, designers just had the original 91 HTML tags to work with.

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

ITNP43: HTML Lecture 4

Lab Introduction to Cascading Style Sheets

Cascading Style Sheets (CSS)

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

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

CSC309 Programming on the Web week 3: css, rwd

CSS. Shan-Hung Wu CS, NTHU

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

Web Development & Design Foundations with HTML5

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

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

CSS Cascading Style Sheets

Html basics Course Outline

Block & Inline Elements

CSS: formatting webpages

Appendix D CSS Properties and Values

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

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

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

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

CSS 1: Introduction. Chapter 3

CSCB20 Week 7. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

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

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

Zen Garden. CSS Zen Garden

CSC309 Winter Lecture 2. Larry Zhang

Web Development & Design Foundations with HTML5

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

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

Chapter 3 Style Sheets: CSS

CSE 154 LECTURE 3: MORE CSS

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

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Scripting for Multimedia LECTURE 5: INTRODUCING CSS3

COMS 359: Interactive Media

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

Certified CSS Designer VS-1028

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

CSS Cont'd: Cascading Style Sheets

Creating and Building Websites

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

Using Advanced Cascading Style Sheets

VISA/APCO/STAC 2P61 WEBSITE CREATION Fall Term 2012

CHAPTER 4 CASCADING STYLE SHEETS BASICS KEY CONCEPTS

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

CS193X: Web Programming Fundamentals

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

Adding CSS to your HTML

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

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

CSS: Cascading Style Sheets

Introduction to Web Tech and Programming

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

CSS - Cascading Style Sheets

HTML & CSS November 19, 2014

INTRODUCTION TO HTML5! CSS Styles!

ID1354 Internet Applications

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 4 The Box Model

The Importance of the CSS Box Model

HTML/CSS. HTML review and extra CSS review CSS Color

Introduction to Computer Science Web Development

Which is why we ll now be learning how to write in CSS (or cascading sheet style)

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

CSc 337 LECTURE 3: CSS

Internet Programming 1 ITG 212 / A

Cascading Style Sheets

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em>

Tutorial 4: Creating Special Effects with CSS

CS 350 Internet Applications I Name: Exam II (CSS) October 29, 2013

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

Faculty of Engineering Department of Computer Engineering. CSS Tutorial. Eng. Ahmed J. Alajrami

INTRODUCTION TO CSS. Topics MODULE 5

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

Three Ways to Use CSS:

Navigation. Websites need a formalized system of links to allow users to navigate the site

Website Design (Weekday) By Alabian Solutions Ltd , 2016

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

Controlling Appearance the Old Way

CSS. Lecture 16 COMPSCI 111/111G SS 2018

Text and Layout. Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11. This presentation 2004, MacAvon Media Productions

Comm 244 Week 3. Navigation. Navigation. Websites need a formalized system of links to allow users to navigate the site

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

Transcription:

CSS: Cascading Style Sheets Computer Science and Engineering College of Engineering The Ohio State University Lecture 13

Evolution of CSS MIME type: text/css CSS 1 ('96): early recognition of value CSS 2 ('98): improvements in language Adding media types (screen vs print) Inconsistent support by browsers CSS 2.1 ('11) In practice since '04 Took forever to standardize CSS 3 Breaks standard into many (50?) modules Various modules already adopted & supported

Key Idea Separate content and style Different languages (syntax):html vs CSS Different documents Goal: Single-point-of-control-over-change Change font of every word in paragraph? Change font of every <em> element in document? Change font of every <em> element in every document on a site? Change font of every <em> element which is part of instructions, but not finalized, on site?

CSS Syntax CSS is declarative (not procedural) Describe a thing, not how to do compute it Example: RE matching CSS = list of rules (order can matter) Rule = a location & the style to use there Basic syntax of a rule selector { property1: style1; property2: style2;... } /*comments always help*/

Example CSS h2 { /* draconian OSU visual identity */ color: darkred; background: gray; /* additional gratuitous styling */ font-style: italic; }

Available Properties (Styles) Background background-color, background-image Text, font line-height, text-align font-size, font-style Border, margin, padding border-left-width, border-bottom-color Positioning clear, display, float Dimension List, table list-style-type border-collapse, caption-side Generated content and other fancy stuff

Shorthand Properties Example: Margins have 4 sides margin-top: 3px; margin-right: 5px; margin-bottom: 7px; margin-left: 9px; Shorthand property: margin margin: 3px 5px 7px 9px; /*TRBL*/ margin: 7px 9px; /*TB sides*/ margin: 2px 6px 8px; /*T sides B*/ Mnemonic: always "TRouBLe" Missing values filled in with provided value(s) Other shorthand properties: Border-width, padding, font, border, background

Including CSS: Mechanics Embed directly in element <p style="color:red;background:gray"> Place in style element in head <head> <style media="screen" type="text/css"> p {color:red; background:gray;} </style> </head> Link to separate CSS file in head <head> <link type="text/css" rel="stylesheet" href="3901style.css" media="screen" /> <head>

Example CSS h2 { } em { } color: darkred; background: gray; font-style: italic; font-style: normal; font-weight: bold;

Tree (Rooted at Body) body element attr name: attr value h1 h2 p h2 p a href: planet.html img src: pic.png alt: a globe em q em

Tree (sans Attributes) body h1 h2 p h2 p a img em q em

Tree (sans Attributes) body h1 h2 p h2 p a img em q h2 { } em { } em

Selectors Applied to Tree body h1 h2 p h2 p a img em q h2 { } em

Selectors Applied to Tree body h1 h2 p h2 p a img em q em { } em

Multiple Selectors h1 { } h2 { } color: darkred; background: gray; font-style: italic; border-bottom-style: solid; color: darkred; background: gray; font-style: italic;

Multiple Selectors: SPOCOC h1, h2 { color: darkred; background: gray; font-style: italic; } h1 { } border-bottom-style: solid; goo.gl/0flzo1

Layout: The Box Model border margin padding Both block & inline Minor differences Border appearance Style, width, color, radius Margins & padding Transparent 4 independent sides Padding is part of it background shows through Margins gives space Some adjacent margins "collapse"

The Box Model As Layers http://geek.focalcurve.com/crashcourse-part2/

Examples

Box Sizing p { margin: 10px 100px 10px 10px; border-width: 5px 1px 5px; width: 200px; padding: 2px; } Total width =? CSS3 adds box-sizing content-box (width sizes content only) border-box (width includes border & padding)

Collapsing Vertical Margins 1 1 2 2

Collapsing Nested Margins

Preventing Margin Collapse padding: 1px

Inheritance for SPOCOC A child inherits many properties from parent by default Font weight, color, family, etc Can be overridden in child Set global styles in root body { font-family: sans-serif; } Contrast this with having to set property in all possible elements! Generally, text properties (eg color) are inherited, box-related (eg border) are not

Example Inheritance body { font-family: sans-serif; background: lightgray; } h2 { color: darkred; background: gray; /*new backgrnd*/ font-style: italic; /*inherits font family*/ } goo.gl/smm4vo

Inherited Properties body h1 h2 p h2 p a img em q em All nodes are sans-serif Most nodes have light gray background

Demo: FF Dev. Inspector, Box

Summary CSS separates style from structure Syntax: Rules with selectors, properties Link to CSS file from HTML document Selectors for picking elements in tree Box Model, padding, border, margin Margins can collapse when overlapping Inheritance Parent passes (font) properties to child Box-related properties aren't inherited