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

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

COSC 2206 Internet Tools. CSS Cascading Style Sheets

Appendix D CSS Properties and Values

Cascading Style Sheets (CSS)

CSS.

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

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

Adding CSS to your HTML

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

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

Assignments (4) Assessment as per Schedule (2)

ID1354 Internet Applications

Web Site Design and Development Lecture 6

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

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

CSS: formatting webpages

Reading 2.2 Cascading Style Sheets

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

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

CSS: Cascading Style Sheets

CSS Styles Quick Reference Guide

CSS. Lecture 16 COMPSCI 111/111G SS 2018

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

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

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

CASCADING STYLESHEETS

CSS Lecture 16 COMPSCI 111/111G SS 2018

Controlling Appearance the Old Way

8a. Cascading Style Sheet

HTML/XML. HTML Continued Introduction to CSS

Tutorial 3: Working with Cascading Style Sheets

Introduction to Web Tech and Programming

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

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

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

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

Creating and Building Websites

Web Design and Development Tutorial 03

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

CSS Cascading Style Sheets

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

CSC309 Programming on the Web week 3: css, rwd

Cascading Style Sheets Level 2

APPLIED COMPUTING 1P01 Fluency with Technology

Cascade Stylesheets (CSS)

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

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

CITS3403 Agile Web Development 2019 Semester 1

Fundamentals of Web Programming a

Overview. Part I: Portraying the Internet as a collection of online information systems HTML/XHTML & CSS

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations).

ITNP43: HTML Lecture 4

Chapter 12: FORMATTING TEXT

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

Zen Garden. CSS Zen Garden

Chapter 4 CSS basics

Introduction to CSS (CSS2) Cascading Style Sheets. CSS Example. CSS Rules

Introduction to WEB PROGRAMMING


CSC 337. Cascading Style Sheets. Marty Stepp, Rick Mercer

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

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

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

CMPT 165: More CSS Basics

BIM222 Internet Programming

CSc 337 LECTURE 3: CSS

Block & Inline Elements

CS 350 COMPUTER/HUMAN INTERACTION. Lecture 6

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

CSS: Formatting Text. CSS for text processing: font-family. Robert A. Fulkerson

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

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

CSS for Styling CS380

escuela técnica superior de ingeniería informática

FLOATING AND POSITIONING

CSS 1: Introduction. Chapter 3

Cascading Style Sheets

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

CSS: Cascading Style Sheets

Introduction to CSS. Fijihosting.com Introduction to CSS page 1. What are style sheets? Lovely! How do I use them?

Chapter 3 Style Sheets: CSS

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

Styles, Style Sheets, the Box Model and Liquid Layout

Cascading Style Sheets. Overview and Basic use of CSS

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

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

EECS1012. Net-centric Introduction to Computing. Lecture 3: CSS for Styling

Creating and Building Websites

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

Lab Introduction to Cascading Style Sheets

CSS. Shan-Hung Wu CS, NTHU

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

Parashar Technologies HTML Lecture Notes-4

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

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

Transcription:

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

Cascading Style Sheets (CSS)

Examples of CSS CSS provides a powerful and stillevolving toolkit of style properties to develop advanced Web apps, e.g.: o http://andrew-hoyer.com/ experiments/rain/ o http://vlog.it/ o http://andrew-hoyer.com/ experiments/walking/

Motivation The Style in Cascading Style Sheets (CSS) refers to o appearance or o layout of a document for viewing, o is distinct from it s structure or meaning How would you design style support into HTML documents? What are the advantages and disadvantages of your approach?

Separation of Concerns HTML (and it s cousin XML) are supposed to be about document structure and meaning. Early in the development of HTML, structure and style were intermixed special tags to control style. Q. What s wrong with this approach? o style is highly localized difficult to apply changes across entire document or set of documents o style is not reusable across elements without copying (repeating) style code o difficult to change style or structure without risking changing the other

Separation of Concerns Burdening HTML with style details leads to tight coupling between style and structure hard to maintain style information spread across documents, changing style requires numerous consistent html tag changes (error prone) difficult to divide responsibility (labour) between designers and document-content creators, who, in the case of dynamic documents, are software developers, not stylists

Style and Document Elements Want a flexible way to bind style(s) to various subsets of document elements Desirable Properties? DRY (don t repeat yourself): should be able to compactly define style to apply to a whole class of elements Inheritance: styles of outer elements should be inherited by inner/nested elements Structural independence: should be able to apply style to document components where ever they occur Context awareness: applied style may vary depending on the structural context in which an element appears

Inheritance Most styles are inherited into nested elements. One way to set a "default" document style is by setting style property values for the <body> element. <style type="text/css"> body { color: green; font-size: 200% } em { font-weight: bold } </style>... <p>this <em>text</em> is green.</p>

Grouping as Selector Multiple comma-separated elements can be grouped, with common style applied to all. without CSS with CSS <style type="text/css"> h1, h3 { color: blue; font-family: helvetica } h2 { font-size: 36pt; new } </style> <body> color: red; font-family: courier <h1>h1</h1> <h2>h2</h2> <h3>h3</h3> </body>

Class AIribute as Selector Special case of attribute selector for HTML documents HTML elements can be tagged with possibly many classes Style properties can be set for all elements of a given class

class AIribute as Selector <style type="text/css">.red { color: red }.large { font-size: 30pt } h1.large { font-size: 40pt } </style>... <h1 class="large">a Heading<h1> <p class="large red">this <em>is</em> the first paragraph. </p> <p class="red">this <em>is</em> the second paragraph.</p>

id AIribute as Selector Any element can have an "id" attribute whose value is unique within the document o can be used as the target for a hyperlink. o used by JavaScript to identify a unique element, e.g. to place dynamic content retrieved from a server. o used to associate style properties with a particular element, e.g. one paragraph from among a list of them. <style type="text/css"> #myid { color:red } </style> <p id="myid">paragraph text in red.</p> Whereas a class selector may apply to several elements, an id selector applies to at most one element.

Contextual Selection CSS can match a search-pattern - on a stack of open elements - designated by a white space - separated list of selectors Ancestors, not just parents can affect style Can mix and match the various types of selectors into selector sentences : div.chapter p.first { font-size: 120% } Apply font-size style to paragraph elements with class first that occur as descendants of div elements with class chapter #x23a p.foo { color: red }

CSS Style Properties Sufficiently expressive for fine-grained control o doesn t give designers a reason to cheat Too many properties to cover comprehensively (many dozens) We ll focus on a few of the most important ones o text properties o layout and positional control, including the box model

CSS Style Properties: color color used to specify foreground element color, especially text background-color used to specify element background color color specified with o a predefined name, e.g. red o RGB (red-green-blue) value expressed in Hex as 6-digit values, e.g. #A0B0C0, or o decimal as 3 values in the range 0-255, e.g. rgb(10,255,100) p { color: green; background-color: #D0E0F0; } q { color: rgb(100,200,10); }

Box FormaIing Model margin (transparent) border padding (transparent) content element width box width Provides a means to control the spatial layout of elements; the basis for position-oriented properties

width, height of box: Box Properties.small { width: 100px; height: 20px }; margin, margin-top, margin-right, margin-bottom, margin-left, and similar properties for border and padding abbreviated way to specify margin, padding: list of values that provide the top/right/bottom/left widths, e.g. span { margin: 1em 2em 3em 4em; }

Box Properties Units can be expressed o px (pixels), cm (centimeters) o em (width of M character) o % (relative to surrounding text) Generally preferable to use relative units such as em or % rather than absolute units like cm, e.g.: div { padding: 1em 2px; margin 2px, 1%, 4cm; }

Box Properties: borders Border property has values to control thickness, style, size of border on each of 4 sides of element border-color, border-width, border-style, border, and many properties for specific sides such as border-bottom-color, e.g. h3 { border-color: blue; } border-style: solid; border-width: thin; h4 { border: #E100D3 dashed 5px; } CSS3 adds a new border- radius property for curved borders 19

Font and Text Properties font-style: normal italic oblique o italic matches if keyword italic or oblique found in known font list o else must match exactly font-variant: normal small-caps o small-caps satisfied if font labelled as such or can be synthesized font-weight: normal bold bolder lighter 100-900 o always matches

Font and Text Properties font-size: absolute relative length percentage text-align: left center right CSS3 text-shadow o horiz-shadow vert-shadow color, e.g. h2 { text-shadow: 5px 5px #EEDDEE }

Font Properties font-family: [family-name generic-family] [, [familyname generic-family]]* generic-families: serif sans-serif cursive fantasy Monospace body { font-family: gill, helvetica, sansserif }

Floats A floated element shifts out of the normal document leftto-right layout flow If there is text beside a float, the text will wrap around the floated element.right_img { float: right; width: 200px; } <img class= right_img src= alt= > To escape the wrapping behavior, use the clear property, which prevents overlap of floating elements q { clear: right; } Clear property possible values: left, right, both, none (default)

Backgrounds background-color: color used too fill the background for an element body { background-color: #1A2B3C ; } background-image: image used for background div.main { background-image: url( movie_poster.jpg ); } background-repeat: repeat a background image, like tiling div.main { background-image: url( movie_banner.jpg ); background-repeat: repeat-x; /* horizontal */ }

How do I use CSS? CSS in a separate document, e.g.: <link rel="stylesheet" type="text/css" href="mystyle.css"> CSS in same document as HTML: Global: style defined within the document head applies to the entire document <style type="text/css"> style definitions </style> Local: style attributes on elements apply only to individual elements <p style="color:blue"> paragraph text in blue </p> Which form is best?

Using CSS <html> <head> <title>css Linking Example</title> <link rel="stylesheet" type="text/css" href="http://www.utsc.utoronto.ca/style.css"/> <style type="text/css"> h1 { color: blue } /* local to document */ </style> </head> <body> <h1>heading in blue</h1> <p style="color:green">paragraph in green.</p> </body> </html>