Cascading Style Sheets Dave Edsall IAGenWeb County Coordinator’s Conference June 30, 2007.

Slides:



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

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
Today CSS HTML A project.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
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.
กระบวนวิชา 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.
Chapter 8 Creating Style Sheets.
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.
Chapter 6 Web Typography
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.
Beginning Web Site Creation: Dreamweaver CS4. XHTMLCSS  Describes the structure  Content  Collection of styles  Formatting body { background-color:
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
4.01 Cascading Style Sheets
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Review: Three parts to a webpage: - Content - Structure  XHTML - Presentation  CSS In this chapter we will focus on introducing and examining the mechanics.
Cascading style sheets (CSS)
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
The Characteristics of CSS
CSS Cascading Style Sheets By Garrett Garman. CSS Why use Style Sheets? Separates Appearance and Structure Modularity Quick and Easy changes Flexibility.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Chapter 6 Web Typography. 2 Principles of Web Design Chapter 5 Objectives Understand principles for type design on a Web site Use the element Understand.
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.
Today’s objectives  Presentational | Inline | Block | Validate  CSS | Rules | Declarations.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Cascading Style Sheets CSS by Pavlovic Nenad by. 2Cascading Style Sheets Presentation Contents What are CSS? What are CSS? History of CSS History of CSS.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
CO1552 – Web Application Development Cascading Style Sheets.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
CSS Cascading Style Sheets. CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
HTML - Quiz #2 Attendance CODE:
XHTML and CSS. The Browser The browser is not print!
CSS October 19. Review of CSS CSS was designed to separate the content of HTML pages from their appearance We are primarily dealing with external style.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
So far, we have looked at CSS selectors that correlate with HTML tags Now, we’ll see how you can define your own selectors using class and ID selectors.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
Cascading Style Sheets Level 2. Course Objectives, Session 1 Level 1 Quick Review Chapter 8: Adding Graphics to Web Pages Chapter 9: Sprucing Up Your.
3. Cascading Style Sheets (CSS) M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer.
Cascading Style Sheets
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
Microsoft Expression Web-Illustrated Unit F: Enhancing a Design with CSS.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
Developing Web Applications with HTML and CSS “Selectors and Properties”
How to… Cascading Style Sheets. How to Insert a Style Sheet When a browser reads a style sheet, it will format the document according to it. There are.
CSS: Cascading Style Sheets Part II. Style Syntax.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 6.
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.
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
EXTERNAL STYLESHEETS AND MORE HTML STYLING HTML and CSS part 2.
Introduction to HTML Dave Edsall IAGenWeb County Coordinator’s Conference June 30, 2007.
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.
CSS (Cascading Style Sheets). CSS CSS – Cascading Style Sheets – Cascade because of the way CSS rules can stack on top of each other. Allows you to add.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
>> Introduction to CSS
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets
Presentation transcript:

Cascading Style Sheets Dave Edsall IAGenWeb County Coordinator’s Conference June 30, 2007

What We Will Cover Enough to get you started A little history for context Why we want to use CSS Basic rules used by all styles Exercises to practice what you will have learned

What We Will Not Cover Every detail of CSS – that’s homework for you How the cascade works How inheritance works Margins, borders, padding and how the box model works. (This isn’t hard to learn) Positioning

So, Let’s Get Started!

Before CSS - Style over Substance Everyone wanted cool web sites Lack of standards enabled browser wars Netscape and Microsoft polluted HTML with their own tags –Remember ? –Do you use ? –What about or ? –What about tables for formatting? Huh? You ARE doing that, aren’t you?

Stop ! - Standards Some thought this was crazy W3C steps in and develops standards for styling web sites HTML standardized with styles removed (4.0) CSS standardized (currently 2.1, 3.0 in the works!)

CSS Permits Style and Substance Styles are separated from content: –HTML holds the content and structures it (paragraphs, sections, pages, lists) –Style sheets tell the browser how to present the content. You can be the author and the typesetter and graphic designer Or, you can be the author and let someone else handle the look-and-feel

How to Add Style Include it inline – put it right into your tags with style=“…” attribute –Useful for one-offs Include it in the document, using and –Useful for single pages Import it from an external file or location or link –Really useful for styling a complete web site

What Can I Style? HTML and XML elements like body, p, a, div, span Element classes Particular elements labelled with IDs

CSS Rules A CSS rule looks like this h1 { font-weight: bold; } ↑ Selector ↑ Property ↑ Value Declaration ↓

Selectors - Elements Let’s give a paragraph a background color Note – there is no selector. The element is its own selector

Exercise 1 – Inline style Start Notepad –Click start -> All Programs -> Accessories -> Notepad Open the file exercise1.html in the folder css –Click File -> Open Look for the paragraph that says “This should be text on a yellow background” In the p tag, add the style attribute style="background-color: yellow;“ Save the file Open the file with your browser. Is the background yellow?

Selectors - Elements Even cooler! Let’s give all paragraphs a border colored red p { border-width: 2px; border-style: solid; border-color: red; } Note – we can apply multiple declarations to an element

Exercise 2 – Document Style Start Notepad Open the file exercise2.html in the folder css Inside the container, after the, add the following: p { border-width: 2px; border-style: solid; border-color: red; } Save the file Open the file with your browser. Are the borders all red?

Selectors - Classes Does it have to be one or all? What if I want some styles for some paragraphs and other styles for other paragraphs? Define classes of styles Especially useful for designing entire web sites.

Selectors - Classes Classes are defined by using a period (.) in the selector p.intro { font-size: large; font-style: italic; } p.obit { font-size: small; font-family: sans-serif }

Selectors - Classes Classes are used with the class attribute in your elements Herein shall ye find the final epitaths of the Lindsay clan who did so bravely defend Castle Edzell David John Lindsay didst fall in battle after consuming an excessive amount of English cheese.

Selectors - Classes Classes are not defined inline. Class can be defined in the document Classes are most often defined in external style sheet files that are imported into several documents

Exercise 3 – Classes Start Notepad Open the file exercise3.html in the folder css Inside the container, after the, add the following: p.intro { font-size: x-large; font-style: italic; } p.obit { font-size: xx-small; font-family: sans-serif; }

Exercise 3 – Classes (cont.) Look for the paragraph with the text “Edsall Family Obituaries In the p tag, add the class attribute class="intro“ Look for the paragraph with the text Delbert Gary Edsall In the p tag, add the class attribute class=“obit“ Save the file Open the file with your browser. Do things look as you expect?

Selectors - IDs What about a style for the elements that occur only once in every document? Every element in a document is an object in the Document Object Model (DOM) Every object in the DOM can have an ID. Associate a style with a given ID

Selectors - IDs IDs are defined using an octothorpe (#) div#navbar { background-color: tan; margin-left: 15px; margin-right: 5px; border: solid black 1px; }

Selectors - IDs IDs are used with the id attribute in your elements (surprise, surprise) <a class=“selected” href=“….

Selectors - IDs Like classes, IDs are not defined inline, can be defined in the document and are most often defined in external style sheet files that are imported into several documents An ID should be unique to each element. But browsers will let you get away with using IDs on more than one element

Real Cool! – Psuedo Classes Called psuedo because they apply to events Events aren’t static objects in your document Event happens – style is applied Most often associated with mouse actions

Psuedo Classes – Mouse Events Example - Links Before the mouse gets there – link Mouse over – hover Mouse click – active After the mouse leaves - visited

Psuedo Classes – Making a Rollover Psuedo classes are defined using an colon after the element (:) div#navbar a { color: #fbf093; } div#navbar a: hover { color: #000; font-weight: bold; }

Psuedo Classes – Making a Rollover The browser then determines when the style needs to be applied depending on what the user does with their mouse <a href=“….

Multiple Selectors Wait! What’s going on with div#navbar a? div#navbar a { color: #fbf093; } Just as a selector can have multiple declarations, a declaration block can be associated with multiple selectors. Here we require that the anchor (a) tag be associated with a div having id=navbar or the style will not be applied. This is POWERFUL!

Who Put the Cascade in CSS? When multiple selectors and styles are associated with an element, what wins? a: link { color: blue; } div#navbar a { color: black; } The browser cascades from lesser importance to higher importance. Whichever declaration is more specific wins. In this case, if we are in a div with id=navbar, the style we have defined for a tags in these divs wins.

Let’s Build a Site!

Exercise 4 – External Style Sheets In the folder CSS you will find an external style sheet named style.css. Open it with Notepad and study it if you wish. We are going to use tables to layout the page. We will have a title bar, a navigation bar and a content area We want the links in our navbar to roll over

Exercise 4 – Importing the Style Sheet Open the file exercise4.html Inside the container, after the, add the url(style.css);

Exercise 4 – Creating a Title Bar After the tag, add Pocahontas County

Exercise 4 – Creating a Navigation Bar Then add For each link to another page, add something like Records

Exercise 4 – Adding Content Then add to close off your navigation bar and begin your content Then type in any content you wish

Exercise 4 – Finishing Up Close off the content and the table by adding Save the file Open your new page with your browser. Do you have a titlebar at the top? Do you have a navigation bar on the left? Do you have content on the right? You could even add a footer to your page by adding another table row at the end.

You Want Power? You can use this page as a template for all your pages If you later decide to change the color of the links on all the pages, you only need to change ONE file - style.css You have the power to make changes to a large site by modifying one file.

Questions?