Creating and Building Websites

Similar documents
Web Site Design. Stanford University Continuing Studies CS 03. Mark Branom

CSS Cascading Style Sheets

CSS.

CSS: The Basics CISC 282 September 20, 2014

Creating and Building Websites

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

CSS: Cascading Style Sheets

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

BIM222 Internet Programming

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

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

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

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

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Cascading Style Sheets (CSS)

CSS Cascading Style Sheets

Cascading Style Sheets CSCI 311

Cascading Style Sheets Level 2

Assignments (4) Assessment as per Schedule (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

CSS. Lecture 16 COMPSCI 111/111G SS 2018

CSS: formatting webpages

DAY 4. Coding External Style Sheets

CMPT 165 Advanced XHTML & CSS Part 3

COSC 2206 Internet Tools. CSS Cascading Style Sheets

CSS Lecture 16 COMPSCI 111/111G SS 2018

Styles, Style Sheets, the Box Model and Liquid Layout

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

Deccansoft Software Services

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

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

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

Lab 4 CSS CISC1600, Spring 2012

CSS: Layout Part 2. clear. CSS for layout and formatting: clear

Cascade Stylesheets (CSS)

Cascading Style Sheets

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

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

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

CSS means Cascading Style Sheets. It is used to style HTML documents.

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

Introduction to Web Design CSS Reference

Cascading Style Sheets. Overview and Basic use of CSS

Introduction to Web Design CSS Reference

8a. Cascading Style Sheet

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

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

Appendix D CSS Properties and Values

HTML/XML. HTML Continued Introduction to CSS

Basic CSS Lecture 17

CSS Styles Quick Reference Guide

CSS: Cascading Style Sheets

2005 WebGUI Users Conference

CE419 Web Programming. Session 3: HTML (contd.), CSS

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

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

Web Development & Design Foundations with HTML5

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

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

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

Web Development & Design Foundations with HTML5

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

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

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

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

CPET 499/ITC 250 Web Systems. Topics

Three Ways to Use CSS:

Chapter 3 Style Sheets: CSS

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

CSS

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

CSC309 Programming on the Web week 3: css, rwd

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


Using Dreamweaver CS6

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

CITS3403 Agile Web Development 2019 Semester 1

Intermediate Web Publishing: Working with Styles

Web Design and Development Tutorial 03

Introduction to Cascading Style Sheets

HTML and CSS COURSE SYLLABUS

INTRODUCTION TO CSS. Topics MODULE 5

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

ITNP43: HTML Lecture 4

Introduction to CSS. 2 Sep 13. Derek Peacock. An introduction to defining CSS style rules using tags, classes and ids.

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

Table of Contents Chapter 9. Working with Cascading Style Sheets ... 1

Setting a Background Image

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

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

Zen Garden. CSS Zen Garden

Class 3 Page 1. Using DW tools to learn CSS. Intro to Web Design using Dreamweaver (VBUS 010) Instructor: Robert Lee

Web Site Design and Development Lecture 5

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

IDM 221. Web Design I. IDM 221: Web Authoring I 1

Introduction to WEB PROGRAMMING

Web Structure and Style. MB2030 Section 2 Class 4

Cascading Style Sheets for layout II CS7026

Transcription:

Creating and Building Websites Stanford University Continuing Studies CS 21 Mark Branom branom@alumni.stanford.edu Course Web Site: http://web.stanford.edu/group/csp/cs21 Week 6 Slide 1 of 28

Week 6 Agenda Unfinished business Cascading Style Sheets Week 6 Slide 2 of 28

CSS Review why called CSS? Cascading Rules are interpreted in a top-to-bottom, cascading fashion. Rules that aren t conflicting are aggregated (e.g., body { background: red; color: white; } produces a background of red with a font color of white. For rules that conflict, last one generally wins (e.g., {background: red; background: white} produces a background of white, not red. Style Refers to the look and feel Sheet Set of rules External, Internal, or Inline Week 6 Slide 3 of 28

CSS Review: Sheet Types (External) External Rules are listed in a separate text file (e.g., style.css) Web pages are attached to the style using the <link> or the @import method: <link href="url-to-style-sheet-file.css" rel="stylesheet" type="text/css" media="all print only screen and (max-width: 640px)"> <style type="text/css" media="all print only screen and (max-width: 640px)"> @import url("url-to-style-sheet-file.css") </style> Week 6 Slide 4 of 28

CSS Review: Sheet Types (Internal) Internal Rules are listed in the web page itself (usually in the <head>) <head> <style type="text/css"> body { background: pink;} </style> </head> Week 6 Slide 5 of 28

CSS Review: Sheet Types (Inline) Inline Rules are listed in the element ( tag ) itself <p style="text-align: center;"> paragraph that's centered </p> Generally used only in email newsletters and computer scripts Week 6 Slide 6 of 28

CSS Review: CSS Rules Rules are defined as a selector and declaration: selector { property: value; } declaration Week 6 Slide 7 of 28

Comments CSS Comments: /* Enter comment here */ /**************** Main section **************/ HTML Comments: <!-- enter comment here --> Week 6 Slide 8 of 28

CSS Selectors: Redefining Elements You can use CSS to redefine an element ( tag ): body { background: pink;} p { font-family: Verdana;} Week 6 Slide 9 of 28

CSS Selectors: Create Own Style (Class/ID) You can use CSS to create your own style:.class { property: value; } #id { property: value;}.highlight { background: #eee; } #headerarea { border: thin dotted #000; } Week 6 Slide 10 of 28

CSS Selectors: Advanced Stuff : Multiple Styles/Selectors Multiple styles Each rule can include multiple styles, using semicolons to separate them. h2 {color: darkblue; font-style: italic;} Multiple selectors that have the same styles can be grouped, using commas to separate them. h1, h2, h3 {font-style: italic;} Week 6 Slide 11 of 28

CSS Selectors: Advanced Stuff : Contextual Selectors Contextual selectors allow you to specify that something will occur only when it is used in conjunction with something else. In the style below, em will display in red, but only when it occurs within li within ul: ul li em {color: red;} Elements being modified by contextual selectors need not appear immediately inside one another. For example, using the style above with the HTML below, blah would still be red text: <ul><li><strong><em> blah </em></strong></li></ul> Week 6 Slide 12 of 28

CSS Selectors: Advanced Stuff : Direct Child Selectors Direct child selectors allow you to specify that something will change, but only when immediately inside another element. With the style below, only those strong elements that are directly inside h1 will be purple font; no strong tags deeper within the sheet will be purple: h1 > strong {color: purple;} Week 6 Slide 13 of 28

CSS Selectors: Advanced Stuff : Adjacent Selectors Adjacent selectors allow you to specify that something will change only when preceded by something else. In the style below, only those links that are preceded by an h2 will be green: h2 + a {color: green;} Elements being modified by adjacent selectors appear immediately after one another. Using the style above, this link would be green: <h2>visit Stanford!</h2> <a href="http://www.stanford.edu">click here</a>. But this link would not: <h2>visit Stanford! <a href="http://www.stanford.edu">click here</a></h2>. Week 6 Slide 14 of 28

CSS and Fonts Some of the things you can do to change fonts in CSS: font-family p { font-family: Verdana;} font-style h1 { font-style: italic;} font-weight.important { font-weight: bolder;} font-size body { font-size: large;} font-variant em { font-variant: small-caps;} text-shadow.cooltext { text-shadow: #f00 3px 3px 5px; } Week 6 Slide 15 of 28

Colors/Backgrounds Colors: 6 digit hex code: #ff0000 3 digit hex code: #f00 rgb method (integer/percentage): rgb(255,0,0) or rgb(100%,0%,0%) keyword color name: red Backgrounds: body { background-color: #f00; } table { background-image: url("/images/bg.gif"); } Week 6 Slide 16 of 28

Span/Div The <span> tag is an inline element and is used to apply style to a small amount of content. Only the word <span class="hightlight"> highlight</span> is highlit. The <div> tag is a block element and is used to apply style to a large amount of content (e.g., regions of a page). <div id="footerarea"> [ footer content ] </div> Week 6 Slide 17 of 28

Pseudo-elements, Pseudo-classes, and Generated Content Pseudo-elements: To affect the first letter, use the style :first-letter To affect the first line, use the style :first-line Pseudo-classes: To affect a link, use the style a:link To affect a visited link, use the style a:visited To affect an active link, use the style a:active To affect a hovered link, use the style a:hover Generated Content: To make content appear before an element, use the style :before with the property content a.msw:before { content: url('msword.gif'); } To make content appear after an element, use the style :after with the property content a.acrobat:after { content: url('adobeacrobat.gif'); } Week 6 Slide 18 of 28

Box model When a browser draws an object on a page, it places it into an invisible rectangular space called a bounding box. You can specify the size, look, and feel of the margins, the padding, the border, the outline, and the content of that bounding box. Week 6 Slide 19 of 28

Making content centered To make a block centered, you need to first give it a width, and then auto-margin the left and right margins: #main { width: 80%; margin-left: auto; margin-right: auto; } nav#mainnavigation { width: 50%; margin: 0px auto 0px auto;} Week 6 Slide 20 of 28

Block vs. Inline Elements are either block or inline. Using CSS, you can change their default status: em { display: block; } p { display: inline; } You can even make them disappear:.hidden { display: none; } Week 6 Slide 21 of 28

Creating a Nav Bar One way to create a nav bar using a list of links and CSS: Week 6 Slide 22 of 28

Absolute Positioning You can also use CSS to define exactly where you want an object to be located, using the property position with a value of absolute: #headersection { position: absolute; top: 0px; left: 0px; width: 100%; } Week 6 Slide 23 of 28

Fixed Positioning You can also use CSS to keep content static and never move: #linksarea { position: fixed; top: 20px; left: 0px; width: 200px; height: 400px; } Week 6 Slide 24 of 28

Layering If two objects are positioned using absolute or fixed positioning, you can layer one on top of the other. To determine which is on top, use the property z-index. The rule with the higher z-index will be on top. In this example, #box1 is on top of #box2, even though #box2 comes after #box1 in the code: #box1 { position: absolute; bottom: 0px; left: 0px; z-index: 5; } #box2 { position: absolute; bottom: 3px; left: 3px; z-index: 1; } Week 6 Slide 25 of 28

Float/Clear You can also have content float to the right or left of another object. float: left; float: right; To end a float, use the clear property: clear: right; clear: left; clear: both; Week 6 Slide 26 of 28

3-column example Week 6 Slide 27 of 28

Next week Forms Basic CGI programming Week 6 Slide 28 of 28