CSC309 Tutorial CSS & XHTML

Similar documents
Outline. Link HTML With Style Sheets &6&7XWRULDO &66 ;+70/ (GZDUG;LD

Appendix D CSS Properties and Values

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

Assignments (4) Assessment as per Schedule (2)

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

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

CSS: The Basics CISC 282 September 20, 2014

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

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

ID1354 Internet Applications

BIM222 Internet Programming

CSS Cascading Style Sheets

CSS: Cascading Style Sheets

CSC 121 Computers and Scientific Thinking

Programmazione Web a.a. 2017/2018 HTML5

COSC 2206 Internet Tools. CSS Cascading Style Sheets

CS 350 COMPUTER/HUMAN INTERACTION. Lecture 6

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

CMPT 165 Advanced XHTML & CSS Part 3

XHTML & CSS CASCADING STYLE SHEETS

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

A Balanced Introduction to Computer Science, 3/E

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

Introduction to Web Tech and Programming

CSS.

Adding CSS to your HTML

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

CSS: Cascading Style Sheets

CSS. Lecture 16 COMPSCI 111/111G SS 2018

Deccansoft Software Services

1 of 7 11/12/2009 9:29 AM

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

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

Cascading Style Sheets

Chapter 3 Style Sheets: CSS

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

CMPT 165: More CSS Basics

CSS Lecture 16 COMPSCI 111/111G SS 2018

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand 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

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

Tutorial 4: Creating Special Effects with CSS

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

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


HTML and CSS COURSE SYLLABUS

Creating A Web Page. Computer Concepts I and II. Sue Norris

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

Web Engineering CSS. By Assistant Prof Malik M Ali

Html basics Course Outline

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

CSS Styles Quick Reference Guide

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

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

Final Exam Study Guide

Index. CSS directive, # (octothorpe), intrapage links, 26

IMY 110 Theme 6 Cascading Style Sheets

Introduction to using HTML to design webpages

Tutorial 3: Working with Cascading Style Sheets

HTML. Hypertext Markup Language. Code used to create web pages

By Ryan Stevenson. Guidebook #3 CSS

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

2005 WebGUI Users Conference

Cascading Style Sheets (CSS)

CSS CSS how to display to solve a problem External Style Sheets CSS files CSS Syntax

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

Web Designing HTML5 NOTES

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

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

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

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

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

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

introduction to XHTML

Module 2 (VI): CSS [Part 3]

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

CASCADING STYLESHEETS

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

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

Lecture 10. CSS Properties. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

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

Chapter 1 Self Test. LATIHAN BAB 1. tjetjeprb{at}gmail{dot}com. webdesign/favorites.html :// / / / that houses that information. structure?

Web Design and Development Tutorial 03

Cascading Style Sheets CSCI 311

Comp-206 : Introduction to Software Systems Lecture 23. Alexandre Denault Computer Science McGill University Fall 2006

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

Lab Introduction to Cascading Style Sheets

8a. Cascading Style Sheet

Zen Garden. CSS Zen Garden

Reading 2.2 Cascading Style Sheets

Tables & Lists. Organized Data. R. Scott Granneman. Jans Carton

Parashar Technologies HTML Lecture Notes-4

Motivation (WWW) Markup Languages (defined). 7/15/2012. CISC1600-SummerII2012-Raphael-lec2 1. Agenda

Web Publishing Basics I

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

CS134 Web Site Design & Development. Quiz1

Introduction to Web Design CSS Reference

CSC309 Programming on the Web week 3: css, rwd

CSS Cascading Style Sheets

Transcription:

CSC309 Tutorial CSS & XHTML Lei Jiang January 27, 2003 1

CSS CSC309 Tutorial --CSS & XHTML 2

Sampel XML Document <?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml-stylesheettype= text/css href= bookdb.css?> <!--File: bookdb.xml --> <!DOCTYPE bookdb [<!ATTLIST chap number ID #REQUIRED>]> <bookdb> <count> 1 </count> <notes> this database stores computer book info </notes> <book isbn="0-13-355592-2"> <author>stephen Chen</author> <title>xml: for Real Programer</title> <content> <chap number="1">the Core of XML</chap> <chap number="2">dom and XSL</chap> <chap number="3">xlink and XPointer</chap> <chap number="4">xml Applications</chap> </content> <description> The web is changing every day. It is not only a place for nifty web pages, but also a communication medium where businesses can perform daily routines. Thus the buzz of e-business is everywhere. "e-business" is not about creating a shopping center on te web. Rather, it is about how a business can communicate with its partners, customers and supplies.... </description> </book> </bookdb> CSC309 Tutorial --CSS & XHTML 3

CSS Language CSS is a declarative language adding formatting information to XML (or HTML) documents. A CSS consists of a set of style rules. A style rule has the form: selector {property list} The selector is used to specify which element the rule applies to. The property list is name-value pairs separated by semicolon (;) e.g. bookdb { display: block } book { display: block; font-size: 16pt; font-weight: bold } title { display: block; margin-bottom: 10px } author { display: block; margin-bottom: 10px } CSC309 Tutorial --CSS & XHTML 4

CSS Selector The most common kind of selector is simply the name of an element. e.g. bookdb {display: block} The universal selector * selects all elements in the document e.g. bookdb {display: block} * {font-size: 10pt; color: blue} Grouping the elements using commas Apply the same rule to multiple elements e.g. count, notes {display: block} CSC309 Tutorial --CSS & XHTML 5

CSS Selector (Cont d) Child Selector A child selector uses the right angle bracket > to select an element if and only if it's an child of the specified parent e.g. bookdb > count {font-size: 14pt} bookdb > notes {font-size: 14pt} Child selector can be jointed as: grandparent > parent > child {property list} Descendant Selector A descendant selector chooses elements that are children, grandchildren, or other descendants of a specified element. e.g. bookdb author {display: block; font-size: 18pt} Attribute selectors Attribute selectors identify specific element/attribute combinations. e.g. book[isbn="0-13-355592-2"] {word-spacing: 10px} Use a = to indicate that the attribute value needs to begin with the specified word. Use a ~= to indicate that the attribute value needs to contain the specified word. CSC309 Tutorial --CSS & XHTML 6

CSS Selector (Cont d) ID selectors Use ID selector to apply a rule to exactly one element with ID type attribute. In our example, the DTD defines the chap element with a ID attribute called number. We can highlight the first chapter using: chap#1 {font-weight: bold} Pseudo-elements Pseudo-elements address parts of the document that aren't identified as separate elements, but need separate styles. The first line of an element The first letter of an element The position immediately before an element The position immediately after an element CSC309 Tutorial --CSS & XHTML 7

CSS Selector (Cont d) Pseudo-elements (Cont d) Addressing the first letter e.g. description {display: block} description:first-letter { } font-size: 300%; float: left; vertical-align: text-top; margin-right: 12px Addressing the first line e.g. description:first-line { font-variant: small-caps } CSC309 Tutorial --CSS & XHTML 8

CSS Selector (Cont d) Pseudo-elements (Cont d) The before and after pseudo-elements select the location immediately before and after the element. The content property is used to put data into this location. E.g. count:before {content: "We have "} count:after {content: "books in the database"} notes:before {content: "Notes: "} notes {margin-bottom:1cm} CSC309 Tutorial --CSS & XHTML 9

CSS Layout When a browser renders an XML document, it places the text from the elements on one or more pages. The text on each page is organized into nested boxes. e.g. Each paragraph is a box. Each line in the paragraph is also a box. As well as paragraphs, there may be tables and lists and other items that are formed from boxes and that are subdivided into smaller boxes In CSS, boxes can have different sizes, borders, margins, padding, and positions. CSC309 Tutorial --CSS & XHTML 10

CSS Box properties border Most boxes don t have borders. They are invisible rectangles that affect the layout of their contents, but are not seen by the readers. You can make a box visible by drawing lines around it using the border properties. Border properties let you specify the style, width, and color of the border. e.g. draw a solid 5-pixel red box around the bookdb (root) element bookdb { border-style: solid; border-width: 5px; border-color: red } Border properties can also be set separately for top, bottom, right and left borders. CSC309 Tutorial --CSS & XHTML 11

CSS Box properties margin & padding Margin properties specify the amount of space added to the box outside its border. Margin may be set separately for the top, bottom, right and left margins using the margin-top, margin-bottom, margin-right, and margin-left properties. Or can be set using shorthand margin. e.g. bookdb { margin: 1cm 1cm 1cm 1cm } The padding properties specify the amount of space on the inside of the border of the box. E.g. bookdb { padding: 2cm 2cm 2cm 2cm } CSC309 Tutorial --CSS & XHTML 12

CSS Box properties result bookdb { border-style: solid; border-width: 5px; border-color: red } bookdb { margin: 1cm 1cm 1cm 1cm } bookdb { padding: 2cm 2cm 2cm 2cm } CSC309 Tutorial --CSS & XHTML 13

CSS Display property Display property can be: none block inline list-item none: Setting display to none hides the element. block: Block-level elements are laid out vertically. The first block is laid out in the top-left corner of the containing block The second block is placed below it. Each block-level element is separated from its sibling and parent elements, generally by placing a line break before and after it. The vertical distance between each block is defined by the individual block s margin and padding properties. Inline: Inline elements are laid out horizontally in a row list-item: same as block with a list-item marker CSC309 Tutorial --CSS & XHTML 14

CSS Display property (Cont d) e.g. chap#1:before {content: "Chapter One: "} chap#2:before {content: "Chapter Two: "} chap#3:before {content: "Chapter Three: "} chap#4:before {content: "Chapter Four: "} chap { display: list-item; list-style-type: disc} chap { position: relative; left: 10px; top: 10px } CSC309 Tutorial --CSS & XHTML 15

CSS Font, color and text properties CSS supports 7 basic font properties font-family, font-size, font-variant, font-weight, and etc. CSS allows you to assign colors to any element by using color property. The value of this color property may be keywords, or an RGB triple in decimal, hexadecimal, or percentages. E.g. bookdb { color: #000000 } book { color: rgb(0, 0, 0) } description { color: rgb(0%, 0%, 100%)} CSS also supports 9 text properties that affect the appearance of text word-spacing, letter-spacing, text-decoration, vertical-align, and etc. http://www.w3.org/style/css/ for more details CSC309 Tutorial --CSS & XHTML 16

The Complete Example CSS <!-- File: bookdb.css --> * {font-size: 10pt; color: blue} bookdb {display: block; background-image: url(bg_1.jpg)} bookdb > count {font-size: 14pt} bookdb > notes {font-size: 14pt} bookdb author {display: block; font-size: 16pt} bookdb title {display: block; font-size: 16pt} bookdb { border-style: solid; border-width: 5px; border-color: red } bookdb { margin: 1cm 1cm 1cm 1cm } bookdb { padding: 2cm 2cm 2cm 2cm } count, notes {display: block} count:before {content: "We have "} count:after {content: "books in the database"} notes:before {content: "Notes: "} notes {margin-bottom:1cm} book[isbn="0-13-355592-2"] {word-spacing: 5px} book {display: block} book { border-style: dashed; border-width: 1px; border-color: black } author:before {content: "Author: "; font-weight: bold; font-style: italic} title:before {content: "Title: "; font-weight: bold; font-style: italic} chap#1 {font-weight: bold} chap#1:before {content: "Chapter One: "} chap#2:before {content: "Chapter Two: "} chap#3:before {content: "Chapter Three: "} chap#4:before {content: "Chapter Four: "} chap { display: list-item; list-style-type: disc} chap { position: relative; left: 60px; top: 10px } description {display: block; margin: 1cm} description:first-letter { font-size: 300%; float: left; vertical-align: text-top; margin-right: 12px} description:first-line { font-variant: small-caps } CSC309 Tutorial --CSS & XHTML 17

The Complete Example result CSC309 Tutorial --CSS & XHTML 18

XHTML CSC309 Tutorial --CSS & XHTML 19

XHTML XHTML is a stricter and cleaner version of HTML XHTML is an XML application Each XHTML document is a well-formed and valid XML document Elements must be properly nested Tag names must be in lowercase All elements must be closed Attribute values must be quoted Empty element tags must end in /> instead of just > E.g. Wrong: <br>, <hr>, <ol><li>item one</ol> Correct: <br />, <hr />, <ol><li>item one</li></ol> Wrong: <input checked> Correct: <input checked="checked" /> CSC309 Tutorial --CSS & XHTML 20

XHTML A simple (minimal) XHTML document <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/tr/xhtml1/dtd/xhtml1- transitional.dtd"> <html> <head> <title>simple document</title> </head> <body> <p>a simple paragraph</p> </body> </html> CSC309 Tutorial --CSS & XHTML 21

XHTML Links <a href="http://www.../course.html">absolute url</a> <a href="course.html">relative url</a> <a href="course.html#end">named anchor </a> <a name="end" /> <a href="mailto:xiaeg@cs.toronto.edu"> email address</a> <a href="course.html"> <img src="flower.gif" alt="link to course page" /></a> <a href="course.html" target="_blank">open a new window</a> <a href="course.html" target="_top">link to the top window</a> <a href="course.html" target="_self >link to the same window</a> CSC309 Tutorial --CSS & XHTML 22

XHTML Frames <html> <frameset rows="75%,25%"> <frame src="r1.html" name="rowone_window" /> <frameset cols="100,*"> <frame src="r2c1.html" scrolling="no" /> <frame src="r2c2.html" scrolling="auto" /> </frameset> </frameset> </html> CSC309 Tutorial --CSS & XHTML 23

XHTML Lists <html><head> <style type="text/css"> ul.level1 {list-style-type: square} ul.level2 {list-style-type: circle} ol{list-style-type: decimal} </style> </head> <body> <ul class="level1"> <li>aaa</li> <ul class="level2"> <li>aaa</li><li>bbb</li><li>ccc</li> </ul> <li>bbb</li> <ol> <li>xxx</li><li>yyy</li><li>zzz</li> </ol> </ul> </body></html> 24 CSC309 Tutorial --CSS & XHTML

XHTML Tables <html><head> <style type="text/css"> td {text-align: center; vertical-align: top; padding: 15} </style></head> <body> <table border="2" cellspacing="20"> <tr> <td colspan="2">aaa</td> </tr> <tr> <td rowspan="2">bbbbb</td> <td>ccc</td> </tr> <tr> <td>dddddddd</td> </tr> </table> </body> </html> CSC309 Tutorial --CSS & XHTML 25

XHTML Forms <html><body> <form name="input" action="formaction.asp"> Enter your first names: <input type="text" name="firstname" value="john" /><br /> Enter your last name: <input type="text" name="lastname" value="smith" /><br /> <input type="submit" value="submit"> </form> <p>click the "Submit" button to send your inputs</p> </body> </html> CSC309 Tutorial --CSS & XHTML 26