Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Intro To Cascading Style Sheets By Mario Yannakakis.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
Cascading Style Sheets
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
/k/k 1212 Cascading Style Sheets Part one Marko Boon
Cascading Style Sheets (CSS) “Styles” for short. Pg. 418.
Cascading Style Sheets
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
CSS. CSS, or Cascading Styles Sheets, is a way to style HTML. Whereas the HTML is the content, the style sheet is the presentation of that document.
Introduction to CSS.
CHAPTER 8 ADVANCED CSS. LEARNING OBJECTIVES Assign formatting styles to a CSS class definition Use a tag’s class attribute to apply the styles defined.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
HyperText Markup Language (HTML) Uses plain text to add markup instructions to a file. If you can't produce it with a standard keyboard, it can't go into.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
CSS cont. October 5, Unit 4. Padding We can add borders around the elements of our pages To increase the space between the content and the border, use.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
Cascading Style Sheets Based on Castro, HTML for the WWW, 6 th edition Ron Gerton, Fall 2007.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
CSS TutorialtMyn1 CSS Tutorial Cascading Style Sheets (CSS) are the modern standard for website presentation. When combined with a structural markup language.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
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} //
“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn.
กระบวนวิชา 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.
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
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.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › 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.
WRT235: Writing in Electronic Environments Basic CSS.
HTML GUIDE Press F5 and then Click on the links on the left to get to the section you want Section 1: Getting Started Section 2: Moving Banner Section.
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
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,
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
CSS Cascading Style Sheets *referenced from
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
Web Development & Design Foundations with XHTML
CS3220 Web and Internet Programming CSS Basics
( Cascading style sheet )
CSS Rule Selector Declaration Block Value Attribute Name body {
>> Introduction to CSS
Madam Hazwani binti Rahmat
Cascading Style Sheets
Cascading Style Sheets: Basics
Website Design 3
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
CS3220 Web and Internet Programming CSS Basics
CS3220 Web and Internet Programming CSS Basics
Stylin’ with CSS.
Web Programming and Design
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets™ (CSS)
Presentation transcript:

Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell

What is CSS? A set of rules for displaying markup content

What is CSS? A set of rules for displaying markup content Cascading: Display rules “cascade” down The most specific rule is used

What is CSS? A set of rules for displaying markup content Cascading: Display rules “cascade” down The most specific rule is used Styles Sheet: Rules are created as styles

The Need for CSS Fixing kludges in HTML

The Need for CSS Fixing kludges in HTML Separation of content and display

The Need for CSS Fixing kludges in HTML Separation of content and display More options for displaying content

The Need for CSS Fixing kludges in HTML Separation of content and display More options for displaying content Efficiency

CSS Example

Visual Display in HTML This will be a heading 1 in red Georgia font Every time I want my text to look the same, I have to retype or cut and paste all of this markup

Style Rules CSS style rules look like this: Selector { property0:value0; property1:value1; propertyZ:valueZ }

CSS Reference

Inline Style Sheet Using a Style Attribute This also shows up as heading 1 in red Georgia font. I don’t have to use the font tag any more. However, I still have to retype or cut and paste the markup every time I want to use the same style. Notice that we switch from the attribute “face” for the “font” element to the property “font-family” in CSS. Names of attributes in HTML do not necessarily exactly match the names of properties in style rules.

Inline Style Sheet Using a Style Attribute In-Class exercise: Create an inline stylesheet that makes all paragraph text black, centered, and 12 pixels in size.

Inline Style Sheet In-Class exercise: Create an inline stylesheet that makes all paragraph text black, centered, and 12 pixels in size. black, centered, 12px text This is black, 12px, centered text.

Embedded Style Sheet Using a Style Element Embedded style sheet h1 {color:red; font-family: Georgia, Times New Roman, Times, serif;} This will also appear as a heading 1 in red Georgia font. In the head of this document, I declared an embedded style sheet that will make all h1 tags in this document red with Georgia font But how do I make some h1 tags use this style and others look different?

Embedded Style Sheet Using a Style Element In-Class exercise: Create an embedded stylesheet that makes all paragraph text blue, background-color #777777, and 14 pixels in size.

Embedded Style Sheet Using a Style Element In-Class exercise: Create an embedded stylesheet that makes all paragraph text blue, background-color #777777, and 14 pixels in size. Embedded style sheet p {color:blue; background-color:#777777; font-size:14px;} This should be blue with gray background and size 14

Class Selectors Embedded style sheet.red {color:red; font-family: Georgia, Times New Roman, Times, serif;} This will also appear as a heading 1 in red Georgia font. In the inline style sheet I declared a generic class style that applies red Georgia to ANY element declared as class red. I simply change a value in the style element in the head and all elements using that style will change to match This will also be in red Georgia font. Now I can be very specific when I apply styles, but I still have to add the same markup in the HEAD to each of my pages. How do I make all my pages use the same styles without copying markup to each page?

Linked Style Sheets Linked style sheet This will also appear as a heading 1 in red Georgia font. In the head of this document I declared a link to an outside stylesheet named “mystyle.css”. In that external stylesheet I place all of the style declarations I was using in my inline stylesheet Now I can change the way all of my pages display simply by modifying a value in my single external stylesheet. How efficient!

Example External Stylesheet h1.redH1 { color:red; font-family: Georgia, Times New Roman, Times, serif } body { background-color: #333333; }.blueback { background-color: blue; color: white } p { font-size: 12px; text-align: center; }

Linked Style Sheet Using an External Stylesheet In-Class exercise: Create an external stylesheet that defines a new style named phunky that makes text pink, centered, and bold. The sheet should also make the background color of the page ”antiquewhite”

Linked Style Sheet Using an External Stylesheet In-Class exercise: Create an external stylesheet that defines a new style named phunky that makes text pink, centered, and bold. The sheet should also make the background color of the page ”antiquewhite”.phunky { color:pink; text-align: center; font-weight: bold; } body{ background-color: antiquewhite }

Cascading revisited When using multiple styles that conflict, which will be displayed?

Cascading revisited When using multiple styles that conflict, which will be displayed? Order: 1. Inline style sheet 2. Embedded style sheet 3. External style sheet 4. Browser default

Style Rule Values Colors: Names for some: blue, red, green, pink Hexadecimal #0000FF, #FF0000, #00FF00, #FF3399 RGB rgb(0,0,255), rgb(255,0,0), rgb(0,255,0) RGB% rgb(0%,0%,100%), rgb(100%,0%,0%)

Style Rule Values Font size: px for pixels (a dot on the screen) font-size: 12px pt for point (1/72 of an inch) font-size: 12pt pc for pica (12 points) font-size: 2pc

Modifying Hyperlinks We can modify the way hyperlinks appear by creating style rules modifying the tag with the following “pseudo- classes”: link visited hover active

Modifying Hyperlinks a:link {color:#0000ff} a:visited {color: #00ff00} a:hover {color:fuschia; font-weight:bold} a:active {font-size:30pt} Order here is important!

Modifying Hyperlinks You can also combine a class selector with a pseudo-class: a.outsidelink:link {color:#0000ff} a.insidelink:visited {color: #00ff00} a.fun:hover {color:fuschia; font-weight:bold}

Span and Div and are tags that let you select a group of elements and apply styles to them is an inline tag no breaks are added before or after is a block tag a break is usually added by the browser before and after the tags

Span and Div Span and Div.red {color:red; font-family: Georgia; font-weight:bold;} This will also appear as normal paragraph text except here because I made the text red,bold, and Georgia font without breaking up the paragraph. Now I am back to normal... I start off as normal paragraph text here as well. However, when I use a div tag to apply a style, my paragraph is broken like this. You can see that the browser sets off this text from the text before and after it. Now I am back to normal again.

Putting it all together In-class exercise: Create a web page with an external style sheet that does the following: All paragraph text is white with a blue background and centered. All links get bigger and change colors when hovered over Background color is “aliceblue” Creates a style “redstyle” that makes text 16px red Garamond. All h1 text is centered and underlined.