CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Similar documents
Appendix D CSS Properties and Values

Reading 2.2 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

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

CSS. Lecture 16 COMPSCI 111/111G SS 2018

CSS Lecture 16 COMPSCI 111/111G SS 2018

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

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

Admin. Midterm 1 on. Oct. 13 th (2 weeks from today) Coursework:

COSC 2206 Internet Tools. CSS Cascading Style Sheets

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

Cascade Stylesheets (CSS)

Cascading Style Sheet Quick Reference

INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations

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

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

CSS: The Basics CISC 282 September 20, 2014

Adding CSS to your HTML

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

Tutorial 3: Working with Cascading Style Sheets

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

Creating A Website - Part 1: Web Design principles, HTML & CSS. CSS Color Values. Hexadecimal Colors. RGB Color

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

HTML/XML. HTML Continued Introduction to CSS

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

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

ACSC 231 Internet Technologies

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

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

Cascading Style Sheets (CSS)

Controlling Appearance the Old Way

Chapter 3 Style Sheets: CSS

ID1354 Internet Applications

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

CSS: Cascading Style Sheets

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

Web Site Design and Development Lecture 5

Introduction to Web Tech and Programming

CSC 443: Web Programming

CSS.

2005 WebGUI Users Conference

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

CSS Cascading Style Sheets

LBS Polytechnic. Hey! Make With The Style Sheet Already, Bub!

8a. Cascading Style Sheet

Fundamentals of Web Programming a

CSS for Styling CS380

Introduction to Cascading Style Sheets

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

IMY 110 Theme 6 Cascading Style Sheets

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

CMPT 165 Advanced XHTML & CSS Part 3

Creating and Building Websites

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

HTML-5.com itemscopehttp://data-vocabulary.org/breadcrumb<span itemprop="title">html 5</span> itemscopehttp://data-vocabulary.

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

Cascading Style Sheets

CASCADING STYLESHEETS

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

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

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

Web Design and Development Tutorial 03

Cascading Style Sheets. Overview and Basic use of CSS

Web Site Design and Development Lecture 6

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

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

Using Dreamweaver to Create Page Layouts

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

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

ITNP43: HTML Lecture 5

ICT IGCSE Practical Revision Presentation Web Authoring

CMPT 165: More CSS Basics

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

Basic Web Pages with XHTML (and a bit of CSS) CSE 190 M (Web Programming), Spring 2008 University of Washington Reading: Chapter 1, sections


Lecture B3 Style : Algorithmic Thinking. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

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

Fundamentals: Client/Server

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

Introducing Cascading Style Sheets. Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS

Methods for configuring Cascading Style Sheets. Applying style to element name selectors. Style Rule Basics. CMPT 165: Cascading Style Sheets

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

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

Web Development & Design Foundations with HTML5

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

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 2

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

ITNP43: HTML Lecture 4

Parashar Technologies HTML Lecture Notes-4

HTML TUTORIAL ONE. Understanding What XHTML is Not

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

Lab Introduction to Cascading Style Sheets

BIM222 Internet Programming

DAY 4. Coding External Style Sheets

> > > > Cascading Style Sheets basics

CSS: formatting webpages

Transcription:

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB Unit 3 Cascading Style Sheets (CSS) Slides based on course material SFU Icons their respective owners 1

Learning Objectives In this unit you will learn the following. Use CSS to style HTML content. Describe commonly used CSS properties. Use CSS to implement a simple visual design. 2

Topics 1. Content vs Style 2. What is CSS? Lecture 1 3. Why CSS? 4. Define Levels and Rules 5. Selectors and Properties 6. Applying Basic Style 7. Adding Style to Report Lecture 2 Lecture 3 3

Nice Webpage Content + Structure + Style Text Images Music Videos PDFs Other Resources Give Meaning HTML: tags, e.g. h1, p attributes hyper links meta data Enhance Message CSS: select tags style rules change visual properties, e.g. resize, colour 4

Style HTML/XHTML is the structured content. Cascading Style Sheets (CSS) is the visual appearance of that content. Without defining style we rely on the browser to choose the appearance, e.g. report. Separating structured content from visual appearance is deliberate. Especially true when we use external CSS files. 5

3 Places to Define Style Mixing style with content! 1. The style="" attribute in a tag. 2. The <style> tag is the <head>. 3. An external CSS file. the best way! Why? 6

New Product Example Say we want to launch of a new product new website content needs to be generated This results in: existing webpage content needs to be modified new webpages and resources need to be added BUT the website style is need not be changed WHAT HAPPENS WHEN STYLE AND CONTENT ARE MIXED? 7 see SparkFun

Style in Content If style and content are mixed then every time a new webpage is added or modified, every time there is a structural change to content, we need to add/modify the affected tag s style. If we decide to change the appearance of (say) <h1>: for every <h1> in every HTML file we need to change the value of the style="" attribute. Same if style is define in the <head> but not as bad. 8

Separating Style Makes designing and later modifying a design easier. Content and its structure can also be change easily. Technical writing (content) and designing (style) are: two separate functions of creating a website, involve two different type of jobs specialization, involve two people, one for each task, content and design and be created in parallel. 9

Amount of Work to Make Style Changes Example: we want to change the style of <h1> 40 webpages 100 <h1> s How many changes are needed at each level? CSS file <style> in <head> amount of work less style="" attribute in a tag more 10

Deprecated Tags def. no longer used Because of CSS: Some tags have been deprecation: e.g. <center> can be replaced with <div style="text- align:center;">content</div> <div> is for division or a section (more than <p>) Use <strong> instead of <b> (bold) Using bold fonts is a way to look strong. Use <em> (emphasis) instead of <i> (italic). Using italic fonts is a way to emphasize text. 11

Deprecated Attributes Because of CSS: Many tag attributes have been deprecated, too! e.g. <hr/> (horizontal rule): attributes align, noshade, size, width GONE! align = "left center right " on the page. noshade = "noshade " render in one solid color. size = "pixels " height of the rule. width = "pixels %" width of the rule. 12

Reasons to Use CSS More options for controlling the appearance of pages compared to old HTML designs. Defining style once in an external file produces smaller files for faster transfer times. Forces authors to separate the meaning of the content from its appearance for better design. Easy to update the appearance of an entire site with external CSS files. Allows you to apply different styles at different times e.g. having a halloween theme in October. Easier for searcher engine to read and parse content. 13

QUESTIONS? 14

Having No Style In many browsers we can turn off styles. What do sites look like without style? CMPT 165 Course Website Microsoft Google Search 15

Levels of CSS? A level in CSS is equivalent to a version. CMPT uses CSS Level 1 or Version 1 (Dec 1996). There many other levels: Level 2 was released in May 1989. Level 2.1 was released in June 2011. Level 3 is being worked on (split into 50 modules). Level 4 is planned for the future. 16

CSS 1 The first official CSS specification by W3C Style support for: Font properties, e.g. typeface and emphasis. Colour of element text, backgrounds. Text attributes, e.g. spacing of words, letters, and lines. Alignment of elements (text, images, etc.) Boxing: margin, border, padding, and positioning. Unique identification of elements. Generic classification of by tag name. The W3C no longer maintains the CSS 1. 17

Style Rules selector { property: value;...} Each property:value; is a declaration. Each rule can have 1 or more declarations. h1 { text- align: center; color: red; } For every <h1> have a horizontal alignment of centre with red coloured text. 18

Style Grouping Group style rules by selector: h1, h2, h3 { font- family: helvetica } Declarations can be grouped: h1 { font- weight: bold; font- size: 12pt; line- height: 14pt; font- family: helvetica; } Grouping of some properties: h1 { font: bold 12pt/14pt helvetica } 19

Style Inheritance In the following HTML: <h1> THE <em> REPORT</em> TITLE </h1> The <em> element would be styled similar to <h1> with red coloured text if the following style rule was declared: h1 { color: red; } 20

Class as Selector When a using the class attribute: <h1 class="title">the REPORT TITLE</h1> We can define a style for that class of element:.title { color: red; } Resulting in: THE REPORT TITLE 21

ID as Selector When a using the id attribute: <h1 id="main">the REPORT TITLE</h1> <h1>1. INTRODUCTION</h1> <p id="main">in summary...</p> <h2 id="main">1.1 ORGANIZATION</p> We can define a style for that class of element: #main { color: blue; } h1#main { color: red; } p#main { color: green; } 22

Contextual Selectors <h1>the <em> REPORT</em> TITLE</h1> If we want all all emphasized on our web page to be red: h1 { color: blue; } em { color: green; } If we only what red emphasized text in <h1> then we: h1 em { color: red; } The emphasized text outside <h1> would be black. THE REPORT TITLE 23

Anchor Pseudo-Classes Some elements have like <a> have specific sub: a:link { color: red; text- decoration: none;} a:visited { color: blue; } a:active, a:hover { text- decoration: underline; } For <a href="#">go To Top</a> this would result in: Go To Top Go To Top Go To Top or Go To Top 24

Typographical Pseudo- Elements Some elements have like <p> have specific sub elements: p:first- line { font- variant: small- caps } p:first- letter { font- size: 200%; float: left } This would result in: 25

Cascading Order How does the browser decide what style rule to use? Styles will cascade into a new virtual style sheet by inheritance and by ordered the replacement of conflicting rules or multiple rules with the same selector. 1. Browser s default 2. External CSS file 3. Internal style sheet (in the <head> section) 4. Inline style (using the style attribute) So, (4) would override (3), (3) overrides (2) and so on. 26

Font Properties font-family - what type of font you want to use e.g. font- family: gill, helvetica, arial; font-style - can be "normal italic oblique" font-variant - can be "normal small- caps" font-weight - can be normal bold bolder lighter 100 900 (e.g. 700 = bold) font-size - can be a absolute/relative-size, length, or % font - short hand to combine all in one line, e.g. font: normal small- caps 120%/120% arial 27

Colour & Background Properties color - the text colour of an element (more in Unit 4) background-color - background colour of an element background-image - have an image as the background background-repeat - have the image repeat, fi small. background-attachment - fixed to canvas or element. background-position - position within the element, e.g. background- position: top right; background - short hand to combine all in one line, e.g. body { color: black; background: white; } 28

Text Properties word-spacing - the space between words, e.g. 1em letter-spacing - the space between characters text-decoration - can be "underline overline line- through blink" vertical-align - e.g. "sub super top middle bottom" text-transform - can be "capitalize uppercase lowercase none" text-align - can be "left right center justify" text-indent - indentation that appears before the first line line-height - line height in number, length, or % 29

Everything Boxed Content - The content of the box, where text and images appear Padding - Clears an area around the content. The padding is transparent Border - A border that goes around the padding and content Margin - Clears an area outside the border. The margin is transparent See http://www.w3schools.com/css/css_boxmodel.asp 30

Box Properties Source: CMPT 165 Course Study Guide, p. 58 31

Box Properties margin: margin-top, margin-right, margin-bottom, margin-left padding: padding-top, padding-right, padding-bottom, padding-left border: border-color, border-style, border-top, border-right, border-bottom, border-left border-width: border-top-width, border-right-width, borderbottom-width, border-left-width width, height: of text or image, images are scaled float: where it will appear in the text "left right none" clear: allows floating elements are not allowed, can be "none left right both" 32

Boxed Example <div> In this course, we shall examine the structure of the Internet and the World Wide Web as well as design and create web sites. </div> Style Rule: Results in 33

Classification Properties Can specify how and where elements are displayed: display: how an element is displayed, can be "block inline list- item none" white-space: how whitespace inside the element is handled, can be "normal pre nowrap" list-style-type: was the type="" attribute for lists list-style-image: use an image as the bullet point list-style-position: how the bullet point is drawn "inside outside" of content list-style: the one liner for above 3 properties 34

Units: Length Specify the length of an element in absolute units: h1 { margin: 0.5in; } - inches, 1in = 2.54cm h2 { line- height: 3cm; } - centimeters h3 { word- spacing: 4mm; } - millimeters h4 { font- size: 12pt; } - points, 1pt = 1/72 in h4 { font- size: 1pc; } - picas, 1pc = 12pt Specify the length of an element in relative units: h1 { margin: 0.5em; } - ems, height of the font h1 { margin: 1ex; } - the height of the letter 'x' h1 { font- size: 9px; } - pixels, relative to canvas img { width: 120%; } - 120% of the body width 35

Units: Colour Specify the colour by name: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow, e.g. h1 { color: maroon; } Specify RGB value: stands for red, blue, green h1 { color: #f00; } - #rgb h1 { color: #ff0000; } - #rrggbb h1 { color: rgb(255,0,0); } - integer range 0-255 h1 { color: rgb(100%, 0%, 0%); } - float range 0.0% - 100.0% 36

Hex Numbering Dec: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F Hexadecimal number FF = decimal number 255, hence the integer range 0-255 in the example: color: rgb(255,0,0); THIS IS IMPORTANT TO REMEMBER!!! 37

QUESTIONS? 38

Class Demo Adding some style to Report 2 URL: Report2 Report4 39

Summary Looked at the reasons why CSS and style are important. Apply cascading style sheets to an XHTML page/site. Learnt about style selectors, properties, and values. Create CSS files that make visual changes to a page. Experiment with the CSS selectors and properties. Next Unit: brining XHTML and CSS together, do more advanced web design. 40

QUESTIONS? 41