“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn.

Slides:



Advertisements
Similar presentations
1 © Netskills Quality Internet Training, University of Newcastle Introducing Cascading Style Sheets © Netskills, Quality Internet.
Advertisements

HIGH LEVEL OVERVIEW: CSS CSS SYNTAX CONSISTS OF A SET OF RULES THAT HAVE 3 PARTS: A SELECTOR, A PROPERTY, AND A VALUE. IT’S NOT NECESSARY TO REMEMBER THIS.
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Intro To Cascading Style Sheets By Mario Yannakakis.
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
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
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
1 Cascading Style Sheets™ (CSS) Outline 5.1 Introduction 5.2 Inline Styles 5.3 Embedded Style Sheets 5.4 Conflicting Styles 5.5 Linking External Style.
Cascading Style Sheets (CSS) “Styles” for short. Pg. 418.
Cascading Style Sheets
Today CSS HTML A project.
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.
Introduction to CSS. What is CSS? A CSS (cascading style sheet) file allows you to separate your web sites (X)HTML content from it’s style. Use your (X)HTML.
Adding styles. Three alternatives HIT151 Web 'n' Net Web Page Basics /*stylesheet*/ h1,h2,h3 { font-family: verdana, arial, 'sans serif'; } p,table,li.
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.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
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.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
CSS TutorialtMyn1 CSS Tutorial Cascading Style Sheets (CSS) are the modern standard for website presentation. When combined with a structural markup language.
CSW131 Steven Battilana 1 CSW 131 – Chapter 5 (More) Advanced CSS Prepared by Prof. B. for use with Teach Yourself Visually Web Design by Ron Huddleston,
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา 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.
Cascading style sheets CSS
Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage.
Cascading Style Sheet (CSS)
I NTRO TO CSS IAT100 Spring I NTRO TO CSS Covered in this lesson: Overview What is CSS? Why to use CSS? CSS for Skinning your Website Structure.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
HTML - Quiz #2 Attendance CODE:
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
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.
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.
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.
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…
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
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.
Introduction to CSS: Selectors
4.01 Cascading Style Sheets
>> Introduction to CSS
Introduction to CSS.
Madam Hazwani binti Rahmat
Introduction to Web programming
Website Design 3
Introduction to CSS.
Introduction to Web programming
Software Engineering for Internet Applications
Introduction to Cascading Style Sheets (CSS)
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets
Introduction to CSS.
Made By : Lavish Chauhan & Abhay Verma
4.01 Cascading Style Sheets
Cascading Style Sheets III B. Com (Paper - VI) & III B
Presentation transcript:

“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn

CSS Advantages  Makes website more flexible  CSS is reusable  Change stylesheet to change design of many pages  Example: CSS Zen garden  Easier to maintain  Cleaner HTML code  Separates styles from HTML tags and page content  Consistent look across entire website that is easily maintained by changing styles in one place.

CSS Disadvantages  Not uniformly supported by all browsers.  Firefox adheres to CSS standards more than IE  For this course we use Firefox

CSS: adding style  CSS allows you to add “style” to an HTML (web page) element  E.g., color, size, or positioning information  There are two aspects to adding style to a web page via CSS  Specifying what the style looks like  Called the CSS style “Declaration”  Naming the HTML (or XML) element to which the style applies  Referred to as specifying the CSS “Selector”

CSS: adding style  The “declaration” part looks a bit like HTML: { font-size: 10px; background-color: #fff; color: #222; margin: 20px; }  The above CSS declaration takes an HTML element and adds a background color, a margin, and changes the element’s font size/color

CSS: adding style  A question : how does the browser know which HTML element on the webpage this declaration applies to? { font-size: 10px; background-color: #fff; color: #222; margin: 20px; }

CSS: adding style  Answer : we precede the declaration with the selector.  For example: body { font-size: 10px; background-color: #fff; color: #222; } …this tells the browser to apply the declared style to the HTML element.

The most basic kind of CSS selector  “ Simple ” type selectors Ex.: body{}, p{}, strong{}  Selects every instance of the corresponding HTML element  These simple selectors are commonly used  Wildcard selector * { }  Selects all elements on a page  Can be used in combination with other selectors

Aside: grouping selectors  You can apply the same declaration to a group of selectors by listing all of the desired selector names separated by commas.  Example: h1, h2, h3, h4, h5, h6 {color:#ff0000; font-family:sans- serif}

CSS: selector flexibility  Th e usefulness of selectors relates to how much specificity you have in selecting different parts of a web page.  Simple example: your personal webpage  You may not want the same font/color type style throughout the entire element

CSS: selector flexibility  You could use the declaration with the selector just for the HTML tag p { font-size: 10px; background-color: #fff; color: #222; } …this tells the browser to apply the declared style to HTML tags. But, what if you want blocks in the About Me section to look one way, and those within your Education section to be styled differently?

Naming HTML elements  There are two naming options for an HTML element: assigning “ID” names and “class names.”  When you give an HTML element a class or id name, you need to use that name when making the corresponding style declaration  These two options are very similar, and the “class name” approach is more popular, so we focus on that.  Aside: An id declaration is the same as a class declaration, except that it should only be used specifically once per web page  The syntax for id vs. class is also nearly identical, the only difference being the use of a pound sign (#) instead of the period (.) you will see in a couple slides.

Example: naming HTML elements  The following HTML block gives the “class name” bigblue to the following specific tag in this (very) simple webpage. Introduction

Connecting a style declaration to a class name  To connect a style declaration to a particular class name you wrote into your HTML document, you simply precede the class declaration with:.theclassname  Example.myboldandbluelook { font-weight: bold; color: blue; } Aside: if you want this style to be used only once in the web page, then specify it as an ID style with this slight syntax change: #myboldandbluelook { font-weight: bold; color: blue; }

More on selector options  Descendant (nested) selector ul li a strong{color:green;}  Syntax is similar to the example of grouping selectors—but without the commas  Selects all elements that correspond to the “nested” structure specified by the selector  E.g., the above style will apply to any HTML tag that lies within an tag that lies within an tag that lies within a tag  Very (!!!) specific—nice!

Aside: styling hyperlinks You can style links to respond dynamically. The associated style selectors are called the hyperlink (or “anchor”) pseudo-class selectors: :link, :visited, :hover, :active { } Example: a:link {color:#FF0000;} /* color to apply to link before it’s visited */ a:visited {color:#00FF00;} /* color to apply to link before it’s visited*/ a:hover {color:#FF00FF;} /* color to apply to link while mouse pointer is over it*/ a:active {color:#0000FF;} /* color to apply while left mouse button is held down on link */  Note: a:hover MUST be listed after a:link and a:visited !  Note: a:active MUST be listed after a:hover !

CSS: what does cascading mean?  Cascading means a more-specific selector beats out a less-specific selector.  For example, with styles....red { color: red; } body { color: black; } What will this HTML look like? I am black I am red

CSS: the cascade  What if there is a “tie” regarding how specific the selectors are? p{font-weight:bold;} p{font-weight:normal;} p{color:green;} This will be green text with a normal font weight  When there is a tie, the tied selector that is most immediately preceding the HTML element wins (in this case, the second “p” selector)  In other words, in a tie, the last-defined selector wins

How/where do we add the style declarations to our HTML files?  Two good approaches for named (class or id) styles:  Internal stylesheet  Put the style declarations in the of HTML text file  External stylesheet  Put the style declarations in a separate text file and then import that text file into your HTML file

How/where do we add the style declarations to our HTML files?  Third approach when you don’t want to bother naming/reusing a style:  Inline style  Simply put the style declaration within the HTML tag where it’s used  Example Text  Note: instead of using an inline (i.e., embedded in HTML) style, we could use our HTML tags Text

Internal Style sheet example CSS Code Here

Preferred method: External Style Sheet  You create a separate style document (example: style.css).  Insert it into your html head tag  Aside: the above “link” tag works for Importing a stylesheet, and there is also an equivalent “ ” tag

Recap: 3 places to define styles  Inline – apply style attribute to a single tag  Takes a lot of work to maintain across a website  Internal, (“embedded,” “global”)  stylesheet defined in the tag of a page  External style sheet (a.css text file)  same functionality as Internal

Resources  Nice description for beginners:  css/ css/  Nice tutorial for beginners:  s s