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.

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

CSS CSS Precise Aesthetic Control. Cascading Style Sheets Though they can be put in HTML header, usually a separate page that the HTML links to Contains.
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.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
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)
CSE CASCADING STYLE SHEETS CSS Faculty of Computer Science and Engineering.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Lecture CSS: Cascading Style Sheets. What are Styles? Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
CSS: Cascading Style Sheets. 2 History HTML tags were originally designed to define the content of a document. The layout of the document was supposed.
CSS1-1 Cascading Style Sheets (CSS) Xingquan (Hill) Zhu
Cascading Style Sheets Example
CSS Dvijesh Bhatt.
HTML - Quiz #2 Attendance CODE:
Cascading style sheets (CSS)
Multimedia & The World Wide Web winny HCI 201 Multimedia and the www.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
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.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
 HTML stands for Hyper Text Mark-up Language. The coding language used to create documents for the World Wide Web  HTML is composed of tags. HTML tags.
Doman’s Sections Information in this presentation includes text and images from
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.
(CSS) More Details Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
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.
HTML - Quiz #2 Attendance CODE:
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
 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 Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
A really fairly simple guide to: mobile browser-based application development (part 2, CSS) Chris Greenhalgh G54UBI / Chris Greenhalgh
3. Cascading Style Sheets (CSS) M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer.
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,
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
REEM ALMOTIRI Information Technology Department Majmaah University.
Cascading Style Sheets Web Design Fairport High School.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Developing Web Applications with HTML and CSS “Selectors and Properties”
CSS: Cascading Style Sheets Part II. Style Syntax.
CSS Cascading Style Sheets *referenced from
Basic Webpage Design Cascading Style Sheet (CSS).
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)
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
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.
1 Cascading Style Sheets
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
WebD Introduction to CSS By Manik Rastogi.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets
Presentation transcript:

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 you to separate visual design elements (layout, fonts, colors, margins, and so on) from the contents of a Web page. Allows for faster downloads, streamlined site maintenance, and global control of design attributes across multiple pages.

3 CSS vs. just HTML What can we do with CSS that we can’t do with HTML? –Control of backgrounds. –Set font size to the exact height you want. –Highlight words, entire paragraphs, headings or even individual letters with background colors. –Overlap words and make logo-type headers without making images. –Precise positioning. –Linked style sheets to control the look of a whole website from one single location. –And more.

4 How to write CSS? Selector –HTML element tags (examples: p, h2, body, img, table) –class and ID names Property (examples: color, font-size) Value (examples: red, 14pt)

5 How to write CSS: The basic syntax of a CSS rule: selector {property 1: value 1; property 2: value 2} Example: p {font-size: 8pt; color: red} Notice the { } around the rule and the : before each value!

6 Three ways to include CSS: 1.Local (Inline) 2.Global (Embedded, or Internal) 3.Linked (External)

7 1. Local Inline style sheet. Placed inside tags. Specific to a single instance of an html tag on a page. Must be used instead of tags to specify font size, color, and typeface and to define margins, etc. Use to override an external or embedded style specification.

8 Local (inline) Example This is a local stylesheet declaration. On the browser:

9 2. Global Embedded or internal style sheet Applicable to an entire document Styles are defined within the tag, which is placed in the header of the html file (i.e., within and ).

10 Global (Internal) Example: Title [DOCUMENT BODY GOES HERE]

11 3. Linked External style sheet Styles are saved in a separate file, with the extension.css This single stylesheet can be used to define the look of multiple pages.

12 Linked (External) Example p {font-family: verdana, sans- serif; font-size: 12pt; color: red} h1 {font-family: serif; font-size: 14pt; color: green} h2 {font-family: serif; font-size: 11pt; color: blue} Save this text file as whatever.css In TextPad,Notepad, etc.…

13 Linked (External) Example (continued) To apply the stylesheet “ whatever.css “ to an HTML document, call it in from the header:

14 Inheritance: which style prevails when several are present? Inline (local) overrides internal (global) Internal (global) overrides external (linked).

15 Cascading The way styles will be used when there is more than one style specified for an HTML element: 1.Browser default 2.External Style Sheet (Linked) (in an external.css file) 3.Internal Style Sheet (Global, or embedded) (inside the tag) 4.Inline Style (Local) (inside HTML element) An inline style (inside an HTML element) has the highest priority, which means that it will override every style declared inside the tag, in an external style sheet, and in the browser (default value).

16 Let’s try this now! Styling with CSS! Write whatever you want here

17 Grouping properties Separate properties with a semi-colon –Example: p {text-align:center;color:red; font- family:Arial; font-style:italic}

18 Grouping selectors Separate selectors with a comma –Example: h1,h2,h3,h4,h5,h6 { color: green } (each header will be green) Separate selectors with a space –Example: p li { color: red } (only items within a list and a paragraph tag will be red)

19 The class Selector With a class selector you can define different styles for the same type of HTML element Examples: First define the class: p.right {text-align: right; color: red; font-style: italic} p.blue {text-align: center; color:blue} Then use the class in your HTML code : This paragraph will be right- aligned, italic, and red. This paragraph will be center- aligned and blue.

20 The class Selector You can also omit the tag name in the selector to define a style that will be used by all HTML elements that have this class. Example:.poem {text-align: center; font-style:italic} Any HTML element with class=“poem" will be center-aligned and italic.

21 The class Selector Example (continued) Both elements below will follow the rules in the ".poem“ class: This heading will be center-aligned and italic This paragraph will also be center-aligned and italic.

22 Class Example p {font-family: sans-serif; font-size: 10pt} h1 {font-family: serif; font-size: 30pt} h2 {font-family: serif; font-size: 24pt}.boldred {color: red; font-weight: bold}.green {color: green}.tinyblue {color: blue; font-size: 8pt} The tags and classes can then be used in combination: This is rendered as 30-point red serif bold text. This is rendered as 10-point red sans-serif bold text.

23 Applying styles to portions of a document: –A division tag: to “package” a block of document into one unit. It defines a block element. –Causes a line break, like and. –“Wraps” a portion of text into a unit, but doesn't cause a line break. Allows styles to be applied to an 'elemental' region (such as a portion of a paragraph).

24 Example This text is rendered as foo-style and this is not. The "foo" style will be applied to this text, and to this text as well.

25 List of style Selectors and their Properties and Values: From WDG:

26 Properties - Font font-family –Name, or serif, sans-serif, cursive, monospace font-style –normal, italic font-weight –normal, bold, 100, 200, 300, 400, 500, 600, 700, 800, 900 font-size –absolute-size, relative-size, length, percentage font-variant –small-caps

27 Properties - Text text-decoration –underline, line-through text-transform –capitalize, uppercase, lowercase, none text-align –left, right, center, justify text-indent –,

28 Properties - Position position –absolute, relative top –,, auto left –,, auto Z-index –, auto

29 A few more details about positioning

30 Positioning Upper left corner corresponds to (0,0) The value of top, bottom, right, left can be expressed in: –Length (measured in px, em, etc…) –Percentage of the parent’s width (0,0) Y X

31 The z-index stacking order is called the z-index. If elements overlap each other, the one with the higher z-index appears on top. Example:.topElement {position: absolute; z-index=2; top:0px; left:0px; font-size:36pt; color:red}

32 CSS Examples: Text in front. –Positioning: ExampleExample –Stacking: ExampleExample –Shadowing: ExampleExample (0,0) Y X

33 Using Boxes and Positioning for layout

34 In a box: Margins are always transparent. Borders come in various styles. Background settings: –the area just inside the borders –includes both the padding and content areas.

35 Examples img { border-style: ridge; border-width: 20px; border-color:red green blue purple} h1 {background-color: #CC66FF; width: 50%; padding: 20px} H1,50%,purple background

36 Border values

37 More fun stuff with CSS

38 Backgrounds background-color –Hex background-image –URL(image.jpg) background-repeat –No-repeat, repeat-x, repeat-y background-attachment –Fixed, scroll background-position –Top, left p { background-position: 70px 10px; background-repeat: repeat-y; background-image: url(background.gif) } Example

39 Background repeat examples:

40 Scroll Bar Color Example: body { color:black; background-color:#a0a0a0; scrollbar-face-color:#903030; scrollbar-arrow-color:#FFFFFF; scrollbar-track-color:#C0B0B0; scrollbar-shadow-color:rgb(0,0,0)} CSS generator for scrollbars: research.com/V2/generators/scrollbar.asp research.com/V2/generators/scrollbar.asp

41 Link Style a:link {color: #FFFFFF; text-decoration: none} a:visited {color: #808080; text-decoration: none} a:hover {color: red; text-decoration: none}

42 Cursor The cursor property specifies the type of cursor to be displayed when pointing on an element. –Crosshair, hand, move, text, wait, etc. Complete demo (cursor styles): ?filename=trycss_cursor ?filename=trycss_cursor

43 How-To Examples (source: w3c) – examples/css-examples.htmlexamples/css-examples.html

44 Linked CSS example: You can download these and try on your own! One html file: css_files/htmlcss7.htmcss_files/htmlcss7.htm The external stylesheet: – css_files/stylecss.csscss_files/stylecss.css The html file can call any stylesheet one at a time for a different design each time.

45 CSS Resources

46 Demos efault.htmhttp:// efault.htm

47 CSS templates and tutorials plex.htmlhttp://positioniseverything.net/guests/3colcom plex.html

48 More CSS links To create a navigation list design: wizards/list-o-matic/list-o-matic.asp To create boxes for layout: als/box_lesson/boxes.html