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

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

UVic Senior s Program: Microsoft Word

Thinking inside the box

brand rationale logo colour typography graphics & images GREEN BISHOP BRAND IDENTITY GUIDELINES

HTML for D3. Visweek d3 workshop

Typography is the art and technique of arranging type in order to make language visible.

HARBORTOUCH STYLE GUIDE

KIDS BEDROOMS SHOP NOW -00% NEW. Item Name & Description $00 $00 -00% NEW. Item Name & Description $00 $00 NEW COLLECTIONS SHOP NOW!

Business Applications Page Format

howtomarketing VISUAL IDENTITY In this section 30/04/ MY PR plus 1

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

PromiseShip Style Guide

BRAND Guide. EuropeActive LOGOS

CASE EXPLORER - INSTALLATION GUIDE. Doc

This is an H1 Header. This is an H2 Header. This is an H3 Header

Chapter 3 CSS for Layout

DESIGN GUIDELINES. Use the following slides as a guide to make sure your presentation follows the PCS Plus brand.

High Performance Auto Layout

Brand Guidelines. Brand Guidelines V1.2 May 21, 2018

INTRODUCTION. As GRADED brand user, you are also responsible for preserving that image. We count on your cooperation in this process.

nagement ompetition enture coaching GRAPHIC STANDARDS capital investment launch opening risk assessment entrepreneur information feasibility study

Styling of Controls Framework

Ad Spec Guidelines

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna - ali qua. Ut enim ad minim veniam,

HTML. UC Berkeley Graduate School of Journalism

[ ] corporate brand guide brought to you from the minds at:

ANNEX VIII.2 New dangerous substances website. Safety and health at work is everyone s concern. It s good for you. It s good for business.

01 The logo design. Our logo is the touchstone of our brand and one of the most valuable assets. We must. Designed by KING DESIGN

Brand Guidelines CONTENTS. About these guidelines...2. Logo usage...3. Color palette...6. Fonts...7. Additional design elements...

STOCKHOLM BEAMER THEME

Manual ODIP Content Management System Version 1.0 February 2013

graceland-core Documentation

Sphinx Readability Theme Documentation

#BDOG2018. Taglines, Hashtags And More. Spice Up Your Messaging. Digital Sharing. Questions? Comments?

15. Recursion 2. Motivation: Calculator. Naive Attempt (without Parentheses) Analyzing the Problem (15 7 3) = Input * 3 = Result 15

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

DESIGNPRINCIPPER FANG FORTÆLLINGEN

Title Optional Subtitle

CSS for Styling CS380

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

Controlling Appearance the Old Way

COMCAS 2015 Author Instructions for Full Manuscript Submission

CSS. Lecture 16 COMPSCI 111/111G SS 2018

CSS: The Basics CISC 282 September 20, 2014

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

Title. Optional subtitle J. Random Author. Cover Text possibly spanning multiple lines ISBN

CSS Lecture 16 COMPSCI 111/111G SS 2018

Appendix D CSS Properties and Values

USER MANUAL. ICIM S.p.A. Certification Mark

CSC 443: Web Programming

CONTENT STRATEGY: What s Real, What s Relevant. Kristina Halvorson Web 2.0 Expo San Francisco

01/ 03/ 05/ 07/ 09/ 11/ 13/ 15/ 17/ 19/ 21/ 23/ WEB DESIGN PRINT DESIGN PERSONAL DESIGN. DESIGN IS: a finely crafted method of mass communication

Ad Spec Guidelines. Ad Spec Guidelines 1

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

Reading 2.2 Cascading Style Sheets

Brand Guidelines Clarity Coverdale Fury

Condition of the Mobile User

CSS, part 1. CS147L Lecture 2 Mike Krieger

CSS.

Case Study: Gut Check App

Feature Extraction and Classification. COMP-599 Sept 19, 2016

COSC 2206 Internet Tools. CSS Cascading Style Sheets

Telly Mamayek, MCWD Director of Communications and Education

The Moldable Editor. Bachelor Thesis. Aliaksei Syrel from Minsk, Belarus. Philosophisch-naturwissenschaftlichen Fakultät der Universität Bern

CSc 337 LECTURE 3: CSS

Assignments (4) Assessment as per Schedule (2)

More CSS. <link href="filename" type="text/css" rel="stylesheet" /> CS380

Technical Document Authoring and

simpleapi Documentation

Dashboard Dashboard Screens Screens

Cascading Style Sheets (CSS)

Introducing Natural Language

Graphic Identity Manual Version 5.0 (Updated 08/17)

Username. Password. Forgot your password? Sign in. Register as new user

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

2005 WebGUI Users Conference

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

sphinx-argparse Documentation

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Elaine Torres/Jeremy Henderson/Edward Bangs

Introduction to MVC 1.0

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 3 Style Sheets: CSS

Demo User Interface and Graphic Guidelines

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

User Manual. Version ,

User Guide. Version 2.3.9,

CSS Cascading Style Sheets

Amplience Content Authoring Cartridge for Salesforce Commerce Cloud

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

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

brand guide book & resources

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

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

Enter the Elephant. Massively Parallel Computing With Hadoop. Toby DiPasquale Chief Architect Invite Media, Inc.

.and we ll give you 100 to say thank you

BOOTSTRAP GRID SYSTEM

Agenda. Combining Rules & Selectors Classes, IDs and DIVs

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

Transcription:

CSC 337 Cascading Style Sheets Marty Stepp, Rick Mercer

Preview of a style sheet /* The good way, with a preview of cascading style sheet (css) that has class mystyle */ body { background-color: grey;.mystyle { border-style: solid; border-width: 2px 20px 10px 30px; border-color: red; margin: 20px; padding: 40px; font-family: Arial, Helvetica, sans-serif; font-size: 1.5em; color: aqua; <body> Default rendering <div class="mystyle">a styled block</div> </body>

Styles on W3Schools The online tutorials have styles like this (okay) in <head> add <style> </style> here <head>

A poor way to produce styles (on W3) W3Schools also shows styles in html tags (not OK) <body> <h1 style="color: blue;">this is a heading</h1> <p style="color: red;">this is a paragraph.</p> </body> Later we'll use a 3 rd way to include CSS styles <head> <title>store CSS code in a separate file</title> <link href="mystyles.css" type="text/css" rel="stylesheet" /> </head>

Cascading Style Sheets (CSS) HTML describes the content of the page CSS describes appearance and layout of information on a web page

Basic CSS rule syntax A CSS file consists of one or more rules Each rule begins with a selector When using a tag like <p>, the style will apply to ALL <p> blocks Between { there are 1 to many style property: value declarations General Form: selector { property: value; property: value;... property: value; Example: p { font-family: sans-serif; color: red;

CSS Properties for Colors <!DOCTYPE html> <html> Property <head> color <title>styles</title> background-color <style> p { color: red; background-color: yellow; </style> </head> <body> <p>this paragraph uses the style above</p> <p>so does this <p></p> </body> </html> Description color of an element s text color that will appear behind the element

<!DOCTYPE html> <html> <head> <title>this is a Title</title> <style> p { color: red; h2 { color: rgb(128, 0, 196); h4 { color: #8000ff; </style> </head> Specifying Colors <body> <p> This paragraph uses the first style above. </p> <h2> This h2 uses the second style above </h2> <h4> This h2 uses the third style above </h4> </body> </html> Color names: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white (white), yellow RGB codes: red, green, and blue values from 0 (none) to 255 (full) Hex codes: RGB values in base-16 from 00 to FF

Fonts Units: pixels (px), point (pt), or m-size (em) for better resizing of web pages 16px, 16pt, 1.16em Vague font sizes: xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger Percentage font sizes: 90%, 120%

CSS Properties for Fonts <!DOCTYPE html> <html> <head> <title>styles</title> <style> p { font-family: Courier; font-size: 8pt; font-style: italic; div { font-family: Arial; font-size: 2em; font-weight: 900; color: blue; </style> </head> <body> <p>arial 8pt italic</p> <div>2em div bold blue</div> </body> </html> property font-family font-size font-style font-weight possible value Courier Arial 8pt 2em normal italic or beak normal bold lighter thickness 100 200 300 800 900 There are a couple dozen more

Multiple font choices Can specify multiple fonts from highest to lowest priority Because some fonts may not exist on the computer If Garamond is not on the computer, try "Times new Roman", then serif p { font-family: Garamond, "Times New Roman", serif; A few commonly used font families Georgia, serif "Times New Roman", Times, serif Arial, Helvetica, sans-serif Or use generic font names, probably best to use: serif, sans-serif, cursive, monospace

Embedding styles in a separate css file CSS can be embedded in HTML (previous slide) or placed in a.css file Use the code below to include the styles you build in the rel attribute means relationship There must be an href present The file name can be anything, but use.css extension If the file is named styles.css, you get them with this <head> <link href="styles.css" type="text/css" rel="stylesheet"> </head>

Backgrounds and an External CSS File /* styles.css */ body { font-size: 1.5em; background-image: url("images/moviebg.png"); h1 { background-color: green; <!DOCTYPE html> <!-- background.html --> <html> <head> <link href="styles.css" type="text/css" rel="stylesheet"> </head> <body> Body has a repeating image, looks like color green <h1>h1 has green background</h1> </body> </html>

/* styles.css */ div { border-style: solid; color: green; width: 160px; height: 120px; p { border-style: double; color: grey; width: 100px; height: 40px; <head> <link href="styles.css" type="text/css" rel="stylesheet"> </head> <div> A div <p>inner paragraph </p> <p>another </p> </div> </body> </html> Borders and external CSS

The CSS Box Model Every HTML element has Content - The content of the box, where text and images appear border - A border that goes around the padding and content padding - Clears an area around the content, inside the element. The padding is transparent. margin - Clears an area outside the border. The margin is transparent

margin and padding /* styles.css */ p { border-style: solid; margin: 5px; padding: 15px; width: 60px; <head> <title>background</title> <link href="styles.css" type="text/css" rel="stylesheet"> </head> <body> <p>one</p> <p>two</p> <p>three</p> </body>

<!DOCTYPE html> <html> <head> <title>box Model</title> <!-- FirstName1 LastName1 --> <!-- FirstName2 LastName2 --> <style> </style> </head> <body> <div> <p> </p> <p> </p> Active Learning Lorem ipsumdolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor Use latin so examples with text do not have distracting words like you are reading </div> </body> Given the HTML file to the left, add the CSS styles to get the appearance as close as possible to the screenshot below

More CSS

Content vs. presentation HTML is for content; what is on the page (heading; list; code; etc.) CSS is for presentation; how to display the page (bold; centered; 20px margin; layouts, etc.) Keeping content separate from presentation is an important web design principle If the HTML contains no styles, its entire appearance can be changed dramatically by swapping.css files See http://csszengarden.com/

Review CSS Syntax / Preview.classes p { /* CSS */ font-family: sans-serif; color: red; A.css file consists of rules Selectors include HTML tags like p table.myclass classes starting with. About 62 other selectors.review { width: 290px; background: lightgray; border: solid <!-- HTML --> <p>the default values of p elements are changed</p> <div class="review">this div has a border now</div>

More Selectors So far, we have only used HTML tags as selectors like p and body To style tables, we have seen selectors table, td, tr We now need class selectors, which is any identifier preceded by '.' Use in HTML with the class attribute /* styles.css */.bordered { border-style: solid; border-width: 6px; padding: 10px; color: grey; width: 120px; height: 20px; <head> <title>class Selector</title> <link href="styles.css" type="text/css" rel="stylesheet"> </head> <body> <p class="bordered"> Styled with a class </p> </body>

text-shadow Shadow is specified as an X-offset, a Y-offset, and a color /* styles.css */.shadowed { font-weight: bold; font-size: 1.8em; color: blue; text-shadow: 2px 6px lightgrey; <head> <title>class Selector</title> <link href="styles.css" type="text/css" rel="stylesheet"> </head> <body> <div class="shadowed"> Styled with a class </div> </body> </html>

background-image, text-align Image repeats to fill all of the HTML block.woodbg { /* CSS */ color: white; text-align: center; background-image: url("images.jpg"); width: 300px; height: 250px; <!-- HTML --> <div class="woodbg"> This entire div should have an image </div>

box-shadow Put a shadow to the right and bottom of an element.box { /* CSS */ /* 10px down, 10px right, 5px thick */ box-shadow: 10px 10px 5px black; border: solid; border-width: 2px; width: 400px; height: 100px; How can we stop this overflow? <!-- HTML --> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="box">lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> </body>

A couple of ways Make the height: value larger, like 200px; Or better yet, use min-height: 100px;

Rounded corners with border-radius Round the border /* CSS */.rounded { border: 3px solid blue; border-radius: 12px; padding: 0.5em; <head> <link rel="stylesheet" href="styles.css"> </head> <body> <body> <p class="rounded"> This is a paragraph </p> <p class="rounded"> This is another paragraph </p> </body>

Vertical Align for an image img { vertical-align: bottom img { vertical-align: middle img { vertical-align: top

span Use <span> to apply a style to part of an inline element No new block start.part { font-size: 1.5em; font-family: sans-serif, "Arial"; <p> Using span to <span class="part">a piece</span> of an element </p>

Styles that conflict When two styles set conflicting values for the same property, the latter style takes precedence p, h1, h2 { color: blue; font-style: italic; h2 { color: red; background-color: yellow; <h1> This h1 has 2 new styles </h1> <h2> This h2 has 3 styles added </h2>