Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54

Slides:



Advertisements
Similar presentations
Chapter 3 © 2003 by Addison-Wesley, Inc Introduction - HTML is primarily concerned with content, rather than style - However, tags have presentation.
Advertisements

© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
Part 3 Introduction to CSS. CSS Text Text Styles h1 {color: green} // rgb(0,255,0), #00ff00 h2{letter-spacing: 0.5cm} // 2px h3 {text-align: right} //
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
Dr. Ahmet Cengizhan Dirican BIL 374 Internet Technologies 3. CSS.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
Web Design & Development Cascading Style Sheets (CSS)
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Cascading style sheets - CSS
COS 381 DAY 3. © 2006 Pearson Addison-Wesley. All rights reserved. 3-2 Agenda Questions? Assignment 1 due January 31 Discussions on CSS –
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
CSS1-1 Cascading Style Sheets (CSS) Xingquan (Hill) Zhu
TECH2018 Multimedia and the Internet More about CSS and Page Layouts.
CP476 Internet Computing Lecture 7 HTML & CSS 1 HTML HyperText Markup Language (HTML) is an application of Standard Generalized Markup Language (SGML)
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 (CSS)
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Cascading Style Sheet (CSS)
1Computer Sciences Department. And use
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 Cascading Style Sheets.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 Cascading Style Sheets.
Cascading Style Sheets " Provide means to control and change presentation of HTML documents. " Allow the user to impose a standard style. " Three levels.
Chapter 3 Cascading Style Sheets Introduction  The CSS1 specification was developed in 1996  CSS2 was released in 1998  CSS3 is on its way 
Chapter 3 © 2012 by Addison Wesley Longman, Inc Introduction - The CSS1 specification was developed in CSS2 was released in CSS2.1.
Chapter 3 © 2010 by Addison Wesley Longman, Inc Introduction - The CSS1 specification was developed in CSS2 was released in CSS3 is.
CSS – Cascading Style Sheets Fred Durao
(CSS) More Details Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Cascading Style Sheet(CSS). Introduction The CSS 1 specification was developed in 1996 CSS 2 was released in 1998 CSS 3 is on its way CSSs provide the.
Cascading Style Sheets (CSS) ICS213, 1 / 2011 Dr. Seung Hwan Kang.
Chapter 3 © 2005 by Addison Wesley Longman, Inc Introduction - The CSS1 specification was developed in CSS2 was released in CSS3 is.
Chapter 3 Cascading Style Sheets. © 2006 Pearson Addison-Wesley. All rights reserved Introduction - The CSS1 specification was developed in 1996.
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.
CO1552 – Web Application Development Cascading Style Sheets.
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.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
 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 Objective: Create an external style sheet, embedded style sheet, and an inline style to change the look and feel of a web site.
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.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
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.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Chapter 3 Cascading Style Sheets. © 2006 Pearson Addison-Wesley. All rights reserved Introduction - The CSS1 specification was developed in 1996.
CSS Cascading Style Sheets *referenced from
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 Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Internet & World Wide Web How to Program, 5/e 1. 2.
3.1 Introduction - HTML is primarily concerned with content, rather
Cascading Style Sheets™ (CSS)
Chapter 6 Cascading Style Sheets™ (CSS)
3.1 Introduction - The CSS1 specification was developed in 1996
3.5 Property Value Forms - There are 60 different properties in 7 categories: - Fonts - Lists - Alignment of text - Margins - Colors - Backgrounds - Borders.
3.1 Introduction - The CSS1 specification was developed in 1996
Cascading Style Sheets™ (CSS)
3.1 Introduction - The CSS1 specification was developed in 1996
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
Presentation transcript:

Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54

Overview Motivation Levels of style sheets Style specification formats Selector forms Property value forms Examples of properties – font, list, color, text alignment, background images

Motivation Consider the management of a corporate web site Site identity (look & feel - e.g. corporate image) must be maintained Changes in site identity must be implemented across the entire site A mixture of content and appearance in a data set is difficult to maintain Stylesheet concept from DTP HTML necessarily mixes style and content, but stylesheets help the separation

CSS CSS provides the means to control and change presentation of HTML documents Style sheets allow you to impose a standard style on a whole document, or even a whole collection of documents CSS1 specification – 1996 CSS2 specification CSS level 2 revision 1 (“CSS 2.1”) is a Candidate W3C Recommendation CSS3 is under development

Levels of Style Sheets There are three levels of style sheets 1.Inline - specified for a specific occurrence of a tag and apply only to that tag This is fine-grain style, which defeats the purpose of style sheets - uniform style 2.Document-level style sheets - apply to the whole document in which they appear 3.External style sheets - can be applied to any number of documents When more than one style sheet applies to a specific tag in a document, the lowest level style sheet has precedence

CSS cascade hierarchy From Web Style Guide: Basic Design Principles for Creating Web Sites, by Patrick J. Lynch and Sarah Horton.

Levels of Style Sheets Inline style sheets appear in the tag itself Document-level style sheets appear in the head of the document External style sheets are in separate files, potentially on any server on the Internet Written as text files with the MIME type text/css A tag is used to specify that the browser is to fetch and use an external style sheet file <link rel = "stylesheet" type = "text/css" href = "

Inline Style Specification Style sheet appears as the value of the style attribute General form: style = "property_1: value_1; property_2: value_2; … property_n: value_n;"

Document Style Specification Style sheet appears as a list of rules that are the content of a tag The tag must include the type attribute, set to "text/css" rule list Form of the rules: selector {property_1:value_1; property_2:value_2; …; property_n:value_n;}

External Style Sheet Specification Form is a list of style rules Like the content of a tag for document-level style sheets

Simple Selector The selector is a tag name or a list of tag names, separated by commas Examples: h1 {font_size: 24pt;} h2, h3 {font_size: 20pt;} Contextual selectors Apply style only to elements in specified position in body of document List element hierarchy body p b {font_size: 30pt}

Class Selector Used to allow different occurrences of the same tag to have different style specifications A style class has a name, which is attached to a tag name p.narrow {property/value list} p.wide {property/value list} The class you want on a particular occurrence of a tag is specified with the class attribute of the tag...

Generic Selectors A generic class can be defined if you want a style to apply to more than one kind of tag A generic class must be named, and the name must begin with a period.really-big { … } Use in body of doc like normal style class …... …

id Selectors An id selector allow the application of a style to one specific element General form: #specific-id {property-value list} e.g. #section3 {font-size: 20} In XHMTL doc: 3. Properties for sale

Pseudo Classes Pseudo classes are styles that apply when something happens, rather than because the target element simply exists Names begin with colons hover class applies when the mouse cursor is over the element focus class applies when an element has focus

Properties Background Border and outline Dimension Font Generated content List There are different properties in 12 categories: Margin Padding Positioning Print Table Text

Property Value Forms Keywords - left, small, … Length - numbers, maybe with decimal points Units: px – pixels in – inches cm – centimeters mm – millimeters pt – points pc - picas (12 points) em - height of the letter ‘m’ ex-height - height of the letter ‘x’ No space is allowed between the number and the unit specification, e.g. 1.5 in is illegal!

Property Value Forms Percentage - just a number followed immediately by a percent sign URL values url(protocol://server/pathname) Colors Color name, e.g. white Hex form: #XXXXXX, e.g. #FFFFFF rgb(n1, n2, n3), e.g. rgb(255, 255, 255) Numbers can be decimal (0-255) or percentages Property values are inherited by all nested tags, unless overridden

Font Properties font-family Value is a list of font names - browser uses the first in the list it has font-size Possible values: a length number or a name, such as smaller, xx-large, etc. font-style italic, oblique (useless), normal font-weight - degrees of boldness bolder, lighter, bold, normal font - for specifying a list of font properties font: bolder 14pt Arial Helvetica Order must be: style, weight, size, font name(s)

List Properties list-style-type On unordered lists list-style-type can be used to specify the shape of the bullets disc (default), square, or circle Set it on either the or tag Fruit Apple Orange Pear On ordered lists list-style-type can be used to change the sequence values

Text and Background Colour The color property specifies colour of text th.red {color: red} th.orange {color: orange} The background-color property specifies the background colour of elements

Background Images The background-image property background-repeat property Possible values: repeat (default), no- repeat, repeat-x, or repeat-y background-position property Possible values: top, center, bottom, left, or right

Text Alignment The text-indent property allows indentation Takes either a length or a % value The text-align property has the possible values, left (the default), center, right, or justify Sometimes we want text to flow around another element - the float property values of left, right, and none (the default)

The and tags One problem with the font properties is that they apply to whole elements, which are often too large Solution: a new tag to define an element in the content of a larger element – The default meaning of is to leave the content as it is.bigred {font-size: 24pt; font-family: Ariel; color: red} … Now is the best time ever!

The and tags The tag is similar to other HTML tags, they can be nested and they have id and class attributes Another tag that is useful for style specifications: Used to create document sections (or divisions) for which style can be specified e.g., a section of five paragraphs for which you want some particular style

Summary Motivation Levels of style sheets Inline, document, external Style specification formats Selector forms Simple, class, generic, id, pseudo classes Property value forms Examples of properties font, list, color, text alignment, background images and tags