CSE 154 Lecture 3: more CSS.

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Contents{ 1. What is CSS? 1. A Brief History of CSS 2. Why to use Styles? 2. Syntax 3. Cascading Order 4. Examples of Properties.
Advertisements

Basics CSS Chapter 3 1.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
CASCADING STYLE SHEETS CSS. 2 What CSS means?  CSS is an extension to basic HTML that allows you to style your web pages.  It separates the part that.
CSE 154 LECTURE 3: MORE CSS. Cascading Style Sheets (CSS): HTML CSS describes the appearance and layout of information on a web page (as opposed.
Web Design & Development Cascading Style Sheets (CSS)
1 CSS Styling with Fonts and Colors. 2 CSS Cascading Style Sheets and fonts CSS provides Style or Presentation options for our html pages CSS properties.
1 Cascading Style Sheets C S S. 2 What is CSS? A simple mechanism for controlling the style of a Web document without compromising its structure. It allows.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
Cascading style sheets - CSS
Lecture CSS: Cascading Style Sheets. What are Styles? Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
© 2007 D. J. Foreman CSS-1 Cascading Style Sheets Styles.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
CSS1-1 Cascading Style Sheets (CSS) Xingquan (Hill) Zhu
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Cascading Style Sheets Example
CSS Dvijesh Bhatt.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Cascading Style Sheet (CSS)
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Cascading Style Sheets, pt 2 ECA 225 Applied Online Programming.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
Cascading Style Sheets " Provide means to control and change presentation of HTML documents. " Allow the user to impose a standard style. " Three levels.
CSS: Cascading Style Sheets. 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
Using Cascading Style Sheet As you create more web pages, you may wish to impose a consistent look for all of your web pages or for group of related pages.
CSS My favourite ICT lesson By Federico Boschi Cascading Style Sheets.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
Cascading Style Sheets Chapter Four. What are they? A set of style rules that tell the web browser how to present a web page or document. Cascading Style.
Class three: CSS review, backgrounds, font formatting, the box model.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
1 Web Development CSS (Cascading Style Sheet). 2 1.Setting rules for multiple elements To decrease the amount of typing for setting rules for multiple.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
CSS for Styling CS The good, the bad and the… ugly!  Tags such as b, i, u, and font are discouraged in strict XHTML  Why is this bad? CS380 2.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Developing Web Applications with HTML and CSS “Selectors and Properties”
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS: Cascading Style Sheets Part II. Style Syntax.
CSS Cascading Style Sheets *referenced from
Basic Webpage Design Cascading Style Sheet (CSS).
Tutorial 3 Designing a Web Page with CSS
03 CSS (Cascading StyleSheet) Р.Жавхлан МОНГОЛ УЛСЫН ИХ СУРГУУЛЬ Мэдээллийн технологийн сургууль Интернэт технологийн үндэс 2015 Намар.
Chapter 11 & 12 CSS Style Sheets: Intro. Why CSS? Separate presentation from content – more accessible Less work – can change appearance of whole site.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
CSS Details Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  To use CSS properties for fonts  Evaluate whether to use pts,
CIS 4004: Web Based IT (CSS) Page 1 © Dr. Mark Llewellyn CIS 4004: Web Based Information Technology Fall 2012 Cascading Style Sheets (CSS) Department of.
Unit 3 - Review. Topics 1. Tag, Attribute, Value 2. CSS Rule Syntax + link 3. Categories of Selectors 4. Inline vs Block Tags 5. CSS Layout 6. CSS Box.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
HTML WITH CSS.
CSS for Styling By Jinzhu Gao.
HTML WITH CSS.
Cascading Style Sheet (CSS)
Introduction to Web programming
Lecture 2: More HTML and CSS
Cascading Style Sheets
Presentation transcript:

CSE 154 Lecture 3: more CSS

Cascading Style Sheets (CSS): <link> <head> ... <link href="filename" type="text/css" rel="stylesheet" /> </head> HTML CSS describes the appearance and layout of information on a web page (as opposed to HTML, which describes the content of the page) can be embedded in HTML or placed into separate .css file (preferred)

Basic CSS rule syntax selector { property: value; ... } p { font-family: sans-serif; color: red; } a CSS file consists of one or more rules a rule's selector specifies HTML element(s) and applies style properties a selector of * selects all elements

Inline styles: the style attribute (BAD!) <p style="font-family: sans-serif; color: red;"> This is a paragraph</p> HTML This is a paragraph output higher precedence than embedded or linked styles used for one-time overrides and styling a particular element this is bad style; DO NOT DO THIS (why?)

Embedding style sheets: <style> (BAD!) <head> <style type="text/css"> p { font-family: sans-serif; color: red; } h2 { background-color: yellow; } </style> </head> HTML CSS code can be embedded within the head of an HTML page this is bad style; DO NOT DO THIS (why?)

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; etc.) keeping content separate from presentation is a very important web design principle If the HTML contains no styles, its entire appearance can be changed by swapping .css files see also: CSS Zen Garden

CSS comments: /* ... */ /* This is a comment. It can span many lines in the CSS file. */ p { color: red; background-color: aqua; } CSS CSS (like HTML) is usually not commented as much as code such as Java the // single-line comment style is NOT supported in CSS the <!-- ... --> HTML comment style is also NOT supported in CSS

W3C CSS Validator jigsaw.w3.org/css-validator/ <p> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a> </p> HTML output jigsaw.w3.org/css-validator/ checks your CSS to make sure it meets the official CSS specifications more picky than the web browser, which may render malformed CSS correctly

CSS properties for fonts property description font-family which font will be used font-size how large the letters will be drawn font-style used to enable/disable italic style font-weight used to enable/disable bold style Complete list of font properties

font-size p { font-size: 14pt; } This paragraph uses the style above. units: pixels (px) vs. point (pt) vs. m-size (em) 16px, 16pt, 1.16em vague font sizes: xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger percentage font sizes, e.g.: 90%, 120%

font-family p { font-family: Georgia; } h2 { font-family: "Courier New"; This paragraph uses the first style above. This h2 uses the second style above. enclose multi-word font names in quotes

More about font-family p { font-family: Garamond, "Times New Roman", serif; } This paragraph uses the above style. can specify multiple fonts from highest to lowest priority generic font names: serif, sans-serif, cursive, fantasy, monospace

font-weight, font-style p { font-weight: bold; font-style: italic; } This paragraph uses the style above. either of the above can be set to normal to turn them off (e.g. headings)

Grouping styles This h2 uses the above styles. p, h1, h2 { color: green; } h2 { background-color: yellow; } CSS This paragraph uses the above style. output This h2 uses the above styles. A style can select multiple elements separated by commas The individual elements can also have their own styles

CSS properties for text property description text-align alignment of text within its element text-decoration decorations such as underlining line-height, word-spacing, letter-spacing gaps between the various portions of the text text-indent indents the first letter of each paragraph Complete list of text properties (http://www.w3schools.com/css/css_reference.asp#text)

text-align blockquote { text-align: justify; } h2 { text-align: center; } CSS The Emperor's Quote [TO LUKE SKYWALKER] The alliance... will die. As will your friends. Good, I can feel your anger. I am unarmed. Take your weapon. Strike me down with all of your hatred and your journey towards the dark side will be complete. output can be left, right, center, or justify (which widens all full lines of the element so that they occupy its entire width)

This paragraph uses the style above. Text-decoration p { text-decoration: underline; } CSS This paragraph uses the style above. output can also be overline, line-through, blink, or none effects can be combined: text-decoration: overline underline;

text-shadow This paragraph uses the style above. output font-weight: bold; text-shadow: 2px 2px gray; } CSS This paragraph uses the style above. output shadow is specified as an X-offset, a Y-offset, and an optional color

The list-style-type property ol { list-style-type: lower-roman; } CSS Possible values: i. none : No marker ii. disc (default), circle, square iii. Decimal: 1, 2, 3, etc. iv. decimal-leading-zero: 01, 02, 03, etc. v. lower-roman: i, ii, iii, iv, v, etc. vi. upper-roman: I, II, III, IV, V, etc. vii. lower-alpha: a, b, c, d, e, etc. viii. upper-alpha: A, B, C, D, E, etc. x. lower-greek: alpha, beta, gamma, etc. others: hebrew, armenian, georgian, cjk-ideographic, hiragana…

CSS properties for backgrounds property description background-color color to fill background background-image image to place in background background-position placement of bg image within element background-repeat whether/how bg image should be repeated background-attachment whether bg image scrolls with page background shorthand to set all background properties

background-image body { background-image: url("images/draft.jpg"); } CSS background image/color fills the element's content area

background-repeat body { background-image: url("images/draft.jpg"); background-repeat: repeat-x; } CSS can be repeat (default), repeat-x, repeat-y, or no-repeat

background-position body { background-image: url("images/draft.jpg"); background-repeat: no-repeat; background-position: 370px 20px; } CSS value consists of two tokens, each of which can be top, left, right, bottom, center, a percentage, or a length value in px, pt, etc. value can be negative to shift left/up by a given amount

The visibility property p.secret { visibility: hidden; } CSS output property description visibility sets whether an element should be shown onscreen;  can be visible (default) or hidden hidden elements will still take up space onscreen, but will not be shown to make it not take up any space, set display to none instead can be used to show/hide dynamic HTML content on the page in response to events

The opacity property body { background-image: url("images/marty-mcfly.jpg"); background-repeat: repeat; } p { background-color: yellow;} p.mcfly1 { opacity: 0.75; } p.mcfly2 { opacity: 0.50; } p.mcfly3 { opacity: 0.25; } CSS property description opacity how not-transparent the element is; value ranges from 1.0 (opaque) to 0.0 (transparent)

box-shadow box-shadow: h-shadow v-shadow blur; CSS box-shadow: 10px 10px 5px; CSS

Styles that conflict This heading uses both styles above. p, h1, h2 { color: blue; font-style: italic; } h2 { color: red; background-color: yellow; } CSS This paragraph uses the first style above. output This heading uses both styles above. when two styles set conflicting values for the same property, the latter style takes precedence

Cascading style sheets It's called Cascading Style Sheets because the properties of an element cascade together in this order: browser's default styles (reference) external style sheet files (in a <link> tag) internal style sheets (in a <style> tag in the page header) inline style (the style attribute of an HTML element)

Inheriting styles (explanation) body { font-family: sans-serif; background-color: yellow; } p { color: red; background-color: aqua; } a { text-decoration: underline; } h2 { font-weight: bold; text-align: center; } CSS This is a heading A bulleted list output A styled paragraph. Previous slides are available on the website. when multiple styles apply to an element, they are inherited a more tightly matching rule can override a more general inherited rule not all properties are inherited (notice link's color above)