Cascading Style Sheets (CSS) Why do we need them? Separate structure from browser presentation There are many HTML presentation attributes –We want to.

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

Computer Applications II.  A Style Sheet is a web page development tool that allows the developer to make global changes to a web page (or web site)
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
กระบวนวิชา 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.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Web-based Application Development Lecture 4 January 19, 2005 Anita Raja.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
Prepared by ackoo Styli n g your page (font type, font size, colors, text decoration, alignment, set margin, table padding, etc.) References: W3Schools.
1 CSS Styling with Fonts and Colors. 2 CSS Cascading Style Sheets and fonts CSS provides Style or Presentation options for our html pages CSS properties.
Web-based Application Development Lecture 5 January 24, 2006 Anita Raja.
First CSS Lecture Applications to HTML
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
Cascading style sheets - CSS
CSS Properties on Parade PropertyValid valuesExample font-familylist of fonts (separate with commas, end with generic font: serif, sans-serif, fantasy,
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
© 2007 D. J. Foreman CSS-1 Cascading Style Sheets Styles.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Formatting Text (Plus More Selectors) Learning Web Design: Chapter 12.
HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks).
TECH2018 Multimedia and the Internet More about CSS and Page Layouts.
XHTML and CSS Introduction to XHTML and CSS Bharti Patel 1 phones off (please)
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,
Cascading Style Sheets Example
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
1.NET Web Forms CSS: Style Sheets © 2002 by Jerry Post.
Cascading Style Sheet (CSS)
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:
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 – Cascading Style Sheets Fred Durao
3-Oct-15 CSS First CSS Lecture Applications to HTML.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
Using Cascading Style Sheet As you create more web pages, you may wish to impose a consistent look for all of your web pages or for group of related pages.
CASCADING STYLE SHEETS. Chapter 3 Objectives Customize HTML elements Specify Font characteristics Classes Tag style Inline and block-level elements External.
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 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
Cascading Style Sheets
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.
1 Web Development CSS (Cascading Style Sheet). 2 1.Setting rules for multiple elements To decrease the amount of typing for setting rules for multiple.
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 for Styling CS The good, the bad and the… ugly!  Tags such as b, i, u, and font are discouraged in strict XHTML  Why is this bad? CS380 2.
Developing Web Applications with HTML and CSS “Selectors and Properties”
CSS Cascading Style Sheets *referenced from
Basic Webpage Design Cascading Style Sheet (CSS).
CSCE Chapter 3 (Cascading Style Sheets) CSCE General Applications Programming Benito Mendoza 1 By Benito Mendoza Department of Computer.
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.
CSS Details Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  To use CSS properties for fonts  Evaluate whether to use pts,
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. Lesson 1: History of CSS CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. There were.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
HTML WITH CSS.
Cascading Style Sheet (CSS)
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Stylin’ with CSS.
Cascading Style Sheets
Cascading Style Sheets
Stylin’ with CSS.
Cascading Style Sheets
Stylin’ with CSS.
Cascading Style Sheets
Cascading Style Sheets
Presentation transcript:

Cascading Style Sheets (CSS) Why do we need them? Separate structure from browser presentation There are many HTML presentation attributes –We want to eliminate the need for these attributes –We want the HTML tags to focus on document structure –We want to standardize HTML specifications Define an entire site’s look and feel in one file –Maintenance is much easier –One change can apply to the whole site –Achieve consistency across the web site Tag related instructions to browsers

Types of Cascading Style Sheets In-line level –Apply to content (e.g. content ) of a single tag –How To: use the style attribute in any tag Document level –Apply to an entire web page –How To: Insert a style tag into the head section External level –Apply to a group of web-pages –How To: Use the link tag to reference a style sheet file Note: In-line styles override document and external styles; document styles override external styles. Hence they cascade.

Style Sheet Syntax Inline: Document Level (The tag must be in section) <!– comment so non CSS browsers will ignore tag { styletype:value; … styletype:value;} tag.stylename {styletype:value; … styletype:value;}.stylename {styletype:value; … styletype:value;} --> External Level (document level syntax without the tag) Examples will follow on subsequent slides

In-line CSS Example This paragraph is uppercase and red. Style types used in this example –text-transform has a value of uppercase –color has a value of red Syntax –Style Type : style value –Separate style specifications using semicolons. –Enclose the style attribute value in quotes. These apply to the content of a single tag

Document Level CSS Example Insert style tag into the head section p {font-size:20pt; font-family: "courier"; text-align:center; font-weight:bold; } Paragraph tags now use the style specifications font size 20 in courier center this paragraph and display bolded

Font Families Separate a series of fonts with commas p {font-family: Lucida, Arial;} Which font will browsers use? –The first one that it knows about –A default if none in the list exists Default families that all browsers recognize –Monospace: all letters have the same width –Others: serif, sans-serif, cursive, or fantasy

HTML Colors Color:#A06033; (A0 red, 60 green, 33 blue) –Value range: ‘00’ to ‘ff’; smaller values are darker Specify colors with hexadecimal (hex) numbers –Hex numbers digits range from 0 to f, not 0 to 9 –A=10, B=11, C=12, D=13, E=14, F=15 –Examples: F9 = 15*16 + 9, 37 = 3* There are web color palettes on the web –Web safe colors look the same on all monitors –Useful so hex codes don’t need to be memorized

Built In HTML Colors ColorNumber Black# Gray# Silver#C0C0C0 White#FFFFFF Red#FF0000 Maroon# Magenta#FF00FF Purple# ColorNumber Blue#0000FF Navy# Aqua#00FFFF Teal# Green# Olive# Lime#00FF00 Yellow#FFFF00

Example with Colors Style tag in the head section h2 {color:red;} h3 {color:#d61130;} Utilize the specifications in the HTML body red text darker red

Example with Fonts Style Tag in head section p {font-style:italic; font-weight:500; font-variant:small-caps; font-size:14pt; line-height:24pt; font-family:Lucida, Arial; } Shorter way to write the same thing p {font: italic 500 small-caps 14pt/24pt Lucida, Arial; }

Other Style Sheet Syntax Style Sheet SpecificationApplies To h1,h2,h3 {font-size:large;}h1, h2, and h3 tags h1#large {font-size:30pt;} #notLarge{font-size:20pt;}Any tag with id="notLarge" a:visited{color:red;}Hyperlink already visited a:link {color: #FF0000;}Unvisited hyperlink a:active {color: #0000FF;}Selected hyperlink a:hover {color: #FF00FF;}Mouse over a hyperlink

Some CSS Styles and Values TypeValue font-familyVerdana, Arial, Serif, "Times New Roman" font-sizexx-small, x-small, small, medium, large, x-large, xx- large larger, smaller, 10px, 20pt, 0.5in font-stylenormal, italic, oblique font-weightnormal, bold, bolder, lighter, 100, 300 font-variantsmall-caps, none text-indent10%, 20cm, 15pt,.5in text-decorationunderline, overline, line-through, blink, none text-transformuppercase, lowercase, capitalize, none text-alignleft, right, center justified Reference:

More CSS Styles and Values TypeValue word-spacing3pt,1cm,.25in letter-spacing3pt, 1cm,.25in margin-top12pt, 2.5cm, 1in margin-bottom12pt, 2.5cm, 1in margin-left12pt, 2.5cm, 1in margin-right12pt, 2.5cm, 1in colorred, #FF0000 background-colorred, #FF0000 background-imageurl(picture.gif`) background-attachmentscroll, fixed Reference:

CSS Classes Style Sheet h1 {font-size:xx-large;} h1.small {font-size:xx-small;}.allTags {font-size:large;} Usage Displays xx-large Displays be xx-small l Any tag can be large

The and tags These tags exist because of CSS –Generic tags that CSS can customize –We can make tags to our own specifications –Eliminate the need for browsers to define new tags tag –Block tag that applies to sections of a document –Example: Displays Red tag –Inline tag that applies to text in a document section –Example: Use doIt style

External Style Sheets Create a text file (Name it with a css extension) Type in the style sheet specifications –Don’t include the style tag –Don’t include HTML comments –CSS comments: /* This is a CSS-comment */ Use link tag in HTML document headers An HTML document can have –More than one link tag –Can have both external and document specifications

More HTML and CSS Help Lots of examples: Documentation –Site for web specification –Site for tutorials and lots of help

Some Review Questions What is a Monospace font? Give an example? What is the advantage of using the font property? How do you use the id attribute with style sheets? How do you change the color of a hyperlink that was already visited? What are differences between inline, document level, and external style sheets? What is a css class? When would you use the and tags? What is a font family?