Styling with Cascading Stylesheets Very Quick Introduction

Slides:



Advertisements
Similar presentations
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
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: 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
Today CSS HTML A project.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
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.
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.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
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.
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.
“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.
Lecture 5. CSS 2 What style will be used when there is more than one style specified for an HTML element? Generally speaking we can say that all the styles.
Cascading Style Sheets 23 rd March. Cascading Style Sheets (CSS) CSS Syntax Linking CSS to XHTML Inheritance & Cascading Order Font Properties Text Properties.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
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…
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.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
WebD Introduction to CSS By Manik Rastogi.
Cascading Style Sheets
Styling with Cascading Stylesheets
Web Development & Design Foundations with XHTML
Internal Style Sheets External Style Sheets
4.01 Cascading Style Sheets
( Cascading style sheet )
CSS: Cascading Style Sheets
CSS Rule Selector Declaration Block Value Attribute Name body {
Chapter 6 Cascading Style Sheets™ (CSS)
Cascading Style Sheets
IS 360 Declaring CSS Styles
Madam Hazwani binti Rahmat
CX Introduction to Web Programming
Web Developer & Design Foundations with XHTML
Cascading Style Sheets
Introduction to Web programming
Cascading Style Sheet (CSS)
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets: Basics
Introduction to CSS.
Introduction to Web programming
Styling with Cascading Stylesheets
Cascading Style Sheets
DynamicHTML Cascading Style Sheet Internet Technology.
آموزش مقدماتی HTML، CSS و Java Script
CS134 Web Design & Development
Stylin’ with CSS.
Cascading Style Sheets
Introduction to Cascading Style Sheets (CSS)
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
DynamicHTML Cascading Style Sheet Internet Technology.
Made By : Lavish Chauhan & Abhay Verma
Web Design & Development
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets
4.01 Cascading Style Sheets
Cascading Style Sheets
Stylin’ with CSS.
Cascading Style Sheets III B. Com (Paper - VI) & III B
Cascading Style Sheets
Introduction to Cascading Style Sheets (CSS)
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

Styling with Cascading Stylesheets Very Quick Introduction * 07/16/96 CSS Styling with Cascading Stylesheets Very Quick Introduction (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

CSS Introduction Cascading Style Sheets (CSS) Markup language, used to describe the presentation of document Defines sizes, fonts, colors, layout, etc. Improves content accessibility Improves flexibility Designed to separate presentation from content Because of CSS all HTML presentation tags are deprecated, e.g. <font> <center> <b> etc.

Style Sheets Syntax Simple syntax, based on English words Contains of set of cascading rules Rule consists of one or more selectors and declaration block Declaration block consists of one or more semicolon-terminated declarations in curly braces Declaration consists of property, a colon and value h1,h2,h3,h4,h5,h6 { color: green }

Style Sheets Syntax (2) Selectors determine which element the rule applies to: All elements of specific type Those that mach specific attribute Elements may be matched depending on how they are nested in the document (HTML)

Style Sheets Syntax (3) Pseudo-classes define further behavior Appended to a selector Examples: :hover, :first-letter, :visited, :before, :after Not all browser support them well

Style Sheets Syntax (4) Three primary types of selectors: By tag: By element id: By element class name (only for HTML): Selectors can be combined with commas: will match <h1> tags, elements with class link and element with id top-link h1 {font-face: Verdana} #element_id {color:#FF0000} .class_name {border: 1px solid red} h1, .link, #top-link {font-weight: bold}

Style Sheets Syntax (5) Match elements, relative to their placement in document: will match all <a> tags that are descendants of <p> tag (may not be direct child!) * - universal selector: will match all child nodes of <p> tag + selector – used to match “following” tag: will match all elements with class name link that appear immediately after <img> tag p a {text-decoration: underline} p * {color: black} img + .link {float:right}

Linking CSS to XHTML 5 options for linking CSS to XHTML: Inline CSS: Used to apply style to one XHTML tag only using the style attribute inside the tag Embedded CSS: Used to apply style to an entire web page using the <style> tag inside the <head> tag External CSS: Used to apply style to an entire website by saving the CSS code in it own external file and using the <link> tag in the <head> section Import CSS: Works the same way as external CSS but uses the @import statement inside the <style> tag Attributes and tags: uses class and id attributes and <span> and <div> tags to allow fine control of style

Inline CSS Included (inlined) in an XHTML tag via the style attribute <b style="color:blue; font-size:16"> text goes here </b>

Embedded CSS <head> … Included in the XHTML code of a web page via the <style> tag <head> … <style type="text/css"> body {color: blue; background: #FFFF00} </style>

External CSS <head> …. CSS code is stored in its own file that the XHTML code of any web page can reference and use <head> …. <link rel="stylesheet" type="text/css" href="cssFile.css"/> </head>

Import CSS A style sheet may be imported with the at-rule - @import <head> ….. <style type="text/css"> @import url("myStyle.css"); @import url("http://www.aa.bb.cc/dd.css"); body {color: blue; background: yellow} </style> …. </head>

Attributes & Tags Apply to all tags: <head> <title></title> <style type="text/css"> @import url("myStyle.css"); @import url("http://www.aa.bb.cc/dd.css"); .shine {color:blue; background:yellow} </style> </head> <body> …. <h1 class=“shine”> Hello World! </h1> … </body>

Attributes & Tags Apply to individual tag: <head> <title></title> <style type="text/css"> @import url("myStyle.css"); @import url("http://www.aa.bb.cc/dd.css"); p.flag {color:blue; font-weight:bold; font-size:16pt} </style> </head> <body> …. <p class=“flag”> Hello World! </p> … </body>

Attributes & Tags Using <div> and <span>: MyStyle.css ……. <head> <title></title> <style type="text/css"> @import url("myStyle.css"); </style> </head> <body> …. <div id=“greeting”> Hello World! </div> … </body> MyStyle.css ……. #greeting {color:blue; font-weight:bold}

Inline Styles Inline styles Individual element’s style defined using style attribute Contains only declaration, no selectors: Override any other styles Apply to all descendant elements Used for styles that are not needed anywhere else on site <p style = "font-size: 20 pt; color: #0000FF">

Inline Styles: Example inline-styles.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Inline Styles</title> </head> <body> <p>Here is some text</p> <!--Separate multiple styles with a semicolon--> <p style="font-size: 20pt">Here is some more text</p> <p style="font-size: 20pt;color: #0000FF" >Even more text</p> </body> </html>

Inline Styles: Example (2) inline-styles.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Inline Styles</title> </head> <body> <p>Here is some text</p> <!--Separate multiple styles with a semicolon--> <p style="font-size: 20pt">Here is some more text</p> <p style="font-size: 20pt;color: #0000FF" >Even more text</p> </body> </html>

Embedded Styles Embedded in the html in <style> tag: Apply to the whole document type attribute specifies the MIME type MIME is a standard for specifying the format of content Other MIME types include text/html, image/gif and text/javascript The <style> tag is placed in the <head> section of the document Used for document-specific style <style type="text/css">

Embedded Styles: Example embedded-stylesheets.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Style Sheets</title> <style type="text/css"> em {background-color: #8000FF;color: white} h1 {font-family: Arial, sans-serif } p {font-size: 18pt} .blue {color: blue} </style>

Embedded Styles: Example (2) … <body> <h1 class="blue">A Heading</h1> <p>Here is some text. Here is some text. Here is some text. Here is some text. Here is some text.</p> <h1>Another Heading</h1> <p class="blue">Here is some more text. Here is some more text.</p> <p class="blue">Here is some <em>more</em> text. Here is some more text.</p> </body> </html>

Embedded Styles: Example (3) … <body> <h1 class="blue">A Heading</h1> <p>Here is some text. Here is some text. Here is some text. Here is some text. Here is some text.</p> <h1>Another Heading</h1> <p class="blue">Here is some more text. Here is some more text.</p> <p class="blue">Here is some <em>more</em> text. Here is some more text.</p> </body> </html>

External CSS Styles External linking link tag (with rel attribute) Separate pages can all use same style sheet Only modify a single file to change styles across your site link tag (with rel attribute) Specifies a relationship between current document and another document link element can only be in the header <link rel="stylesheet" type="text/css" href="styles.css">

External Styles: Example styles.css /* CSS Document */ a { text-decoration: none } a:hover { text-decoration: underline; color: red; background-color: #CCFFCC } li em { color: red; font-weight: bold } ul { margin-left: 2cm } ul ul { text-decoration: underline; margin-left: .5cm }

External Styles: Example (2) external-styles.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Importing style sheets</title> <link type="text/css" rel="stylesheet" href="styles.css" /> </head> <body> <h1>Shopping list for <em>Monday</em>:</h1> <li>Milk</li> …

External Styles: Example (3) … <li>Bread <ul> <li>White bread</li> <li>Rye bread</li> <li>Whole wheat bread</li> </ul> </li> <li>Rice</li> <li>Potatoes</li> <li>Pizza <em>with mushrooms</em></li> <a href="http://food.com" title="grocery store">Go to the Grocery store</a> </body> </html>

External Styles: Example (4) … <li>Bread <ul> <li>White bread</li> <li>Rye bread</li> <li>Whole wheat bread</li> </ul> </li> <li>Rice</li> <li>Potatoes</li> <li>Pizza <em>with mushrooms</em></li> <a href="http://food.com" title="grocery store">Go to the Grocery store</a> </body> </html>