1Computer Sciences Department. And use

Slides:



Advertisements
Similar presentations
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 External Style.
Advertisements

Today CSS HTML A project.
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.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
Client-Side Internet and Web Programming
CSS(Cascading Style Sheets )
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} //
กระบวนวิชา 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 Cascading Style Sheets Brief Introduction
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Web Design & Development Cascading Style Sheets (CSS)
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Cascading Style Sheets Example
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
CSS Dvijesh Bhatt.
Cascading style sheets (CSS)
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.
WORKING WITH CASCADING
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
INTRODUCTION TO HTML5 Styling Text. Change the Font Size  You can use the font-size property to change the font size for a document’s text.  Instead.
Doman’s Sections Information in this presentation includes text and images from
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
CSS – Cascading Style Sheets Fred Durao
To Proudly supported by ferrycake.com. We will be printing Cash for your Community tokens every week in the Carmarthen Journal and Llanelli Star. The.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
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.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
CHAPTER 3 CSS & CSS3 อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
DIV, Span, CSS.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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,
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Web Foundations MONDAY, OCTOBER 7, 2013 LECTURE 7: CSS LINK COLORS, INTERMEDIATE CSS.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS: Cascading Style Sheets Part II. Style Syntax.
1 CSS محمد احمدی نیا 2 Of 21 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements 
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.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
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 solve a problem External.
1 Cascading Style Sheets
WebD Introduction to CSS By Manik Rastogi.
CSS.
Cascading Style Sheet.
( Cascading style sheet )
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
CSS Style Sheets: Intro
Cascading Style Sheets
Cascading Style Sheets
Presentation transcript:

1Computer Sciences Department

And use

Cascading Style Sheets CSS

 Introduction to CSS  Cascading Style Sheets  Benefits of using CSS  Levels of Style Sheets  CSS Syntax  Properties  CSS3 Objectives

 The CSS1 specification was developed in 1996  CSS2 was released in 1998  CSS3 is the latest standard for CSS and is completely backwards-compatible with earlier versions of CSS  CSSs provide the means to control and change presentation of HTML documents (control the style and layout of multiple Web pages all at once).  CSS is not technically HTML, but can be embedded in HTML documents  Style sheets allow you to impose a standard style on a whole document, or even a whole collection of documents  Style is specified for a tag by the values of its properties Computer Sciences Department5 Introduction

 CSS stands for Cascading Style Sheets  CSS defines how HTML elements are to be displayed  Styles were added to HTML 4.0 to solve a problem  CSS saves a lot of work  External Style Sheets are stored in CSS files Computer Sciences Department6 What is CSS?

 HTML was NEVER intended to contain tags for formatting a document.  HTML was intended to define the content of a document, like:  This is a heading  This is a paragraph.  When tags like, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large web sites, where fonts and color information were added to every single page, became a long and expensive process.  To solve this problem, the World Wide Web Consortium (W3C) created CSS.  In HTML 4.0, all formatting could (and should!) be removed from the HTML document, and stored in a separate CSS file. Computer Sciences Department7 CSS Solved a Big Problem

 The style definitions are normally saved in external.css files.  With an external style sheet file, you can change the look of an entire Web site by changing just one file! Computer Sciences Department8 CSS Saves a Lot of Work!

 There are three levels of style sheets Inline - specified for a specific occurrence of a tag and apply only to that tag – This is fine-grain style, which defeats the purpose of style sheets - uniform style Document-level style sheets - apply to the whole document in which they appear External style sheets - can be applied to any number of documents  When more than one style sheet applies to a specific tag in a document, the lowest level style sheet has precedence  In a sense, the browser searches for a style property spec, starting with inline, until it finds one (or there isn’t one) Computer Sciences Department9 Levels of Style Sheets

 There are three ways of inserting a style sheet:  Inline style  Internal style sheet  External style sheet Computer Sciences Department10 Three Ways to Insert CSS

 - To use inline styles, add the style attribute to the relevant tag. - The style attribute can contain any CSS property. Computer Sciences Department11 Inline Styles

 An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, inside the tag, like this: Computer Sciences Department12 Internal Style Sheet

Computer Sciences Department13

Computer Sciences Department14 CSS Syntax

 CSS selectors allow you to select and manipulate HTML elements.  CSS selectors are used to "find" (or select) HTML elements based on their id, class, type, attribute, and more. Computer Sciences Department15 CSS Selectors

 The element selector selects elements based on the element name.  All elements can be selected on a page like this: (all elements will be center-aligned, with a red text color) Computer Sciences Department16 The element Selector

 The id selector uses the id attribute of an HTML element to select a specific element.  An id should be unique within a page, so the id selector is used if you want to select a single, unique element.  To select an element with a specific id, write a hash character, followed by the id of the element. Computer Sciences Department17 The id Selector

 The class selector selects elements with a specific class attribute.  To select elements with a specific class, write a period character, followed by the name of the class.  You can also specify that only specific HTML elements should be affected by a class. Computer Sciences Department18 The class Selector Red and center-aligned heading Red and center-aligned paragraph.

Computer Sciences Department19 Try Grouping Selectors

 There are 60 different properties in 7 categories:  Backgrounds  Alignment of text  Fonts  Lists  Margins  Colors  Borders Computer Sciences Department20 Properties

 Keywords - left, small, …  Not case sensitive  Length - numbers, maybe with decimal points  Units:  px - pixels  in - inches  cm - centimeters  mm - millimeters  pt - points  pc - picas (12 points)  em - height of the letter ‘m’  ex-height - height of the letter ‘x’  No space is allowed between the number and the unit specification e.g., 1.5 in is illegal! Computer Sciences Department21 Property Values

 The background-color property specifies the background color of an element.  With CSS, a color is most often specified by:  a HEX value - like "#ff0000"  an RGB value - like "rgb(255,0,0)"  a color name - like "red“  The background-image property specifies an image to use as the background of an element.  background-repeat  background-attachment  background-position Computer Sciences Department22 CSS Background

Computer Sciences Department23

Computer Sciences Department24

Computer Sciences Department25 Text Alignment

Computer Sciences Department26 Text Decoration The text-decoration property is mostly used to remove or add underlines from links for design purposes

 The text-transform property is used to specify uppercase and lowercase letters in a text.  It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word  The text-indent property is used to specify the indentation of the first line of a text. Computer Sciences Department27 Text Transformation and Indentation

Computer Sciences Department28 CSS font

 Font Family: P {font-family: "Times New Roman", Times, serif;}  Font Style:  Font Size  Set Font Size With Em: font-size: 2.5em; /* 40px/16=2.5em */ (To allow users to resize the text. 1em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px. The size can be calculated from pixels to em using this formula: pixels/16=em)  Use a Combination of Percent and Em: font-size: 100%; Computer Sciences Department29 Font Properties

 Links can be styled with any CSS property (e.g. color, font- family, background, etc.).  Links can be styled differently depending on what state they are in.  The four links states are:  a:link - a normal, unvisited link  a:visited - a link the user has visited  a:hover - a link when the user mouses over it  a:active - a link the moment it is clicked  A pseudo-class is used to define a special state of an element  Example Example Computer Sciences Department30 Styling Links and CSS Pseudo-classes

 In the following example, the selector matches the first element in all elements Computer Sciences Department31 Match the first element in all elements first-linefirst-line and first-letterfirst-letter

 The CSS list properties allow you to:  Set different list item markers for ordered lists  Set different list item markers for unordered lists  Set an image as the list item marker  In HTML, there are two types of lists:  unordered lists ( ) - the list items are marked with bullets  ordered lists ( ) - the list items are marked with numbers or letters  With CSS, lists can be styled further, and images can be used as the list item marker. For exampleFor example  List - Example List - Example Computer Sciences Department32 CSS Lists

Computer Sciences Department33

Computer Sciences Department34

 Table Borders: table, th, td { border: 1px solid black;}  Table Width and Height: table {width: 100%;}  Horizontal Text Alignment “left, right, or center”: th {text-align: left;}  Vertical Text Alignment ” top, bottom, or middle”: td { height: 50px; vertical-align: bottom;}  Table Padding  Table Color  table, td, th { border: 1px solid green; } th { background-color: green; color: white; } td { padding: 15px; } Computer Sciences Department35 CSS Tables

Computer Sciences Department36 CSS Box Model

Computer Sciences Department37

Computer Sciences Department38

 The margin clears an area around an element (outside the border).  The margin does not have a background color, and is completely transparent.  The top, right, bottom, and left margin can be changed independently using separate properties.  A shorthand margin property can also be used, to change all margins at once.  Example Example Computer Sciences Department39 Margin

 The display property specifies if/how an element is displayed.  The visibility property specifies if an element should be visible or hidden.  visibility: hidden; hides an element, but it will still take up the same space.  display: none; element will be hidden, and the page will be displayed as if the element is not there  li {display:inline;} displays elements as inline elements. Computer Sciences Department40 CSS Display and Visibility

 The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big.  There are four different positioning methods:  Static Positioning: HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page. “are not affected by the top, bottom, left, and right properties”  Fixed Positioning: An element with a fixed position is positioned relative to the browser window, and will not move even if the window is scrolled  Relative Positioning: A relative positioned element is positioned relative to its normal position  Absolute Positioning: An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is. Computer Sciences Department41 CSS Positioning

 The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).  An element with a larger z-index generally covers an element with a lower one Computer Sciences Department42

Computer Sciences Department43

 With CSS float, an element can be pushed to the left or right, allowing other elements to wrap around it.  Float is often used with images, but it is also useful when working with layouts Computer Sciences Department44 CSS Float

 Navigation Bar = List of Links  Home News Contact About  Horizontal Navigation Bar: li {display: inline;} Computer Sciences Department45 CSS Navigation Bar

 Creating transparent images with CSS is easy.  The CSS opacity property is a part of the CSS3 recommendation  The CSS3 property for transparency is opacity  IE9, Firefox, Chrome, Opera, and Safari use the property opacity for transparency. The opacity property can take a value from A lower value makes the element more transparent.  IE8 and earlier use filter:alpha(opacity=x). The x can take a value from A lower value makes the element more transparent.  Example Example Computer Sciences Department46 CSS Image Opacity / Transparency

Css3 Computer Sciences Department47

 CSS3 allows you to format your elements using 3D transforms.  The 3D transform methods:  rotateX()  rotateY()  More More Computer Sciences Department48 CSS3 3D Transforms

 An animation lets an element gradually change from one style to another.  You can change as many properties you want, as many times you want.  You can specify when the change will happen in percent, or you can use the keywords "from" and "to" (which represents 0% and 100%).  0% represents the start of the animation, 100% is when the animation is complete.  When an animation is created in rule, you must bind it to a selector, otherwise the animation will have no effect.  Bind the animation to a selector (element) by specifying at least these two properties:  the name of the animation  the duration of the animation  more more Computer Sciences Department49 CSS3 Animations