CSS - Cascading Style Sheets. What is CSS ? css defines how to display an html document (fonts, colors, layouts etc.) were added to HTML 4.0 specification.

Slides:



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

Building a Website: Cascading Style Sheets (CSS) Fall 2013.
Client-Side Internet and Web Programming
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
กระบวนวิชา 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.
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
Working with Cascading Style Sheets
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
W EB S ITE L ECTURE C ASCADING S TYLE S HEETS. Cascading Style Sheets (CSS) Introduction CSS Objectives – Provide more control over web site content presentation.
Chapter 8 Cascading Style Sheets (CSS). Agenda Definition of a CSS style Types of CSS Styles CSS Backgrounds CSS Text CSS Fonts CSS Links CSS Lists CSS.
Slide 1 of 83 Table Borders To specify table borders in CSS, use the border property. The example below specifies a black border for table, th, and td.
Cascading Style Sheets Example
Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.
Cascading Style Sheets Billy Toy Cascading Style Sheets Syntax review How to Implement style sheets Background properties Text properties.
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.
LING 408/508: Programming for Linguists
1Computer Sciences Department. And use
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
CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.
Tutorial 4 Creating Special Effects with CSS
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Doman’s Sections Information in this presentation includes text and images from
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.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 7.
Lecture # 33 Cascade Style Sheets (CSS). Cascade Style Sheets (CSS): Preserving a consistent “look and feel” of a website across multiple pages.
CHAPTER 3 CSS & CSS3 อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
CSS Class 2 -Add margins to elements on a page. -Set width and height of elements. - CSS shorthand properties for box model. -Style links. -Style tables.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
LING 408/508: Programming for Linguists Lecture 10 September 30 th.
Web Development & Design Foundations with HTML5 7th Edition
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
Web Foundations MONDAY, OCTOBER 7, 2013 LECTURE 7: CSS LINK COLORS, INTERMEDIATE CSS.
Copyright © Osmosys O S M O S Y SO S M O S Y S D e p l o y i n g E x p e r i e n c e & E x p e r t i s e™ CSS Training.
CSS – Cascading Style Sheets
Lecture 2: Cascading Style Sheets (CSS) Instructor: Dr. M. Anwar Hossain.
JavaScript and CSS
CSS: Cascading Style Sheets Part II. Style Syntax.
Advanced CSS. Display  Hiding an element can be done in two ways  display:none  Element is hidden and will no longer take up space on the page  Can.
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.
Introduction To CSS. History of CSS ► ► CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. ► ► There were.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Unit 3 - Review. Topics 1. Tag, Attribute, Value 2. CSS Rule Syntax + link 3. Categories of Selectors 4. Inline vs Block Tags 5. CSS Layout 6. CSS Box.
1 Cascading Style Sheets
WebD Introduction to CSS By Manik Rastogi.
CSS.
Chapter 7 Page Layout Basics Key Concepts
Web Development & Design Foundations with HTML5 8th Edition
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Presentation transcript:

CSS - Cascading Style Sheets

What is CSS ? css defines how to display an html document (fonts, colors, layouts etc.) were added to HTML 4.0 specification to solve a problem usually css styles are specified in an external file enables developers to change the layout and look of all documents in a web site by just editing a single file

Need for CSS HTML was intended to define the structure of a document (i.e. headings, paragraphs, tables etc.), not the formatting of an element when style attributes like font, color, background etc. were introduced, maintaining a large web page in which formatting/style information was scattered all over the document became a nightmare for web developers so, HTML 4.0 allowed formatting information to be removed from the document and placed separately (in.css files)

A simple CSS example body {background-color: #aabbcc} h1 {font-style: italic; font-size: 36pt} h2 {color: blue} p {margin-left: 50px} it specifies that: the tag should have a background color of #aabbcc the heading tag should use an italic font of size 36pt the heading tag should use a blue color for displaying text a paragraph tag should start at an offset of 50 pixels on the left

CSS syntax rules selector { property: value; property: value; …} where selector can be: a tag name; ex.: p { font-family: sans-serif } a group of tags; ex.: h1, h2, h3, h4, h5, h6 { color: red } a class name (with or without a tag name): p.right { text-align: right }.right { text-align: right } … in html document: Right aligned text an ID (with or without a tag name): div#green { color: green } #green { color: green } … in html document: Green div… pseudo-classes and pseudo-elements

Pseudo-classes syntax: selector:pseudo-class {property: value; …} selector.class:pseudo-class {property: value; …} list of pseudo-classes: anchor pseudo-classes: a:link {color:#FF0000} /* unvisited link */ a:visited {color:#00FF00} /* visited link */ a:hover {color:#FF00FF} /* mouse over link */ a:active {color:#0000FF} /* selected link */ :first-child: matches an element that is the first child of any other element;ex.: p:first-child { color: blue } > selector:first-child: matches an element that is the first child of a specific element; ex.: p > i:first-child { color: blue} :lang: adds a style to an element with a specific lang attribute :active: adds a style to an element that has keyboard input focus

Pseudo-elements syntax: selector:pseudo-element {property: value; …} selector.class:pseudo-element {property: value; …} list of pseudo-elements: :first-letter – adds style to the first character of a text div:first-letter { font-size: xx-large; } :first-line – adds style to the first line of a text div:first-line { color: red } :before – adds content before an element h1:before { content: url(smiley.jpg)} :after – adds content after an element h1:after { content: url(smiley.jpg)}

Adding style sheets to a document external style sheet: internal style sheet: p { margin-left: 10px } inline style sheet: <p style=“color: red; margin-left: 10px}

Multiple style sheets if multiple style sheets are defined, their priority is (ascending order): 1) browser default 2) external style sheet 3) internal style sheet 4) inline style

Background properties PropertyDescription backgroundSets all the background properties in one declaration background-attachmentSets whether a background image is fixed or scrolls with the rest of the page background-colorSets the background color of an element background-imageSets the background image for an element background-positionSets the starting position of a background image background-repeatSets how a background image will be repeated

Background CSS example div { background-color:#0f0f0f; background-image:url(‘back.jpg'); background-repeat:repeat-x; background-position:top right; }

Border and outline properties PropertyDescription borderSets all the border properties in one declaration border-bottomSets all the bottom border properties in one declaration border-bottom-colorSets the color of the bottom border border-bottom-styleSets the style of the bottom border border-bottom-widthSets the width of the bottom border border-colorSets the color of the four borders border-leftSets all the left border properties in one declaration border-left-colorSets the color of the left border border-left-styleSets the style of the left border border-left-widthSets the width of the left border border-rightSets all the right border properties in one declaration border-right-colorSets the color of the right border border-right-styleSets the style of the right border border-right-widthSets the width of the right border border-styleSets the style of the four borders border-topSets all the top border properties in one declaration border-top-colorSets the color of the top border border-top-styleSets the style of the top border border-top-widthSets the width of the top border border-widthSets the width of the four borders outlineSets all the outline properties in one declaration outline-colorSets the color of an outline outline-styleSets the style of an outline outline-widthSets the width of an outline

Border CSS example div { border-top-style: solid; border-bottom-style: solid; border-left-style: dotted; border-right-style: dotted; border-width: 2px; border-color: #00ff00; }

Dimension properties PropertyDescription heightSets the height of an element max-heightSets the maximum height of an element max-widthSets the maximum width of an element min-heightSets the minimum height of an element min-widthSets the minimum width of an element widthSets the width of an element

Font properties PropertyDescription fontSets all the font properties in one declaration font-familySpecifies the font family for text font-sizeSpecifies the font size of text font-styleSpecifies the font style for text font-variantSpecifies if a text should be displayed in a small-caps font font-weightSpecifies the weight of the font

Font CSS example p, div { font-family:”Times New Roman”, Arial, Serif; font-style: italic; font-size: 12px; }

List properties PropertyDescription list-styleSets all the properties for a list in one declaration list-style-imageSpecifies an image as the list-item marker list-style-positionSpecifies where to place the list-item marker list-style-typeSpecifies the type of list-item marker

List CSS example ul { list-style-type: circle; list-style-position: inside; }

Margin and padding properties PropertyDescription marginSets all the margin properties in one declaration margin-bottomSets the bottom margin of an element margin-leftSets the left margin of an element margin-rightSets the right margin of an element margin-topSets the top margin of an element paddingSets all the padding properties in one declaration padding-bottomSets the bottom padding of an element padding-leftSets the left padding of an element padding-rightSets the right padding of an element padding-topSets the top padding of an element

Margin CSS example div { margin-top: 100px; margin-bottom: 100px; margin-left: 5%; margin-right: 5%; }

Positioning properties PropertyDescription bottomSets the bottom margin edge for a positioned box clearSpecifies which sides of an element where other floating elements are not allowed clipClips an absolutely positioned element cursorSpecifies the type of cursor to be displayed displaySpecifies the type of box an element should generate floatSpecifies whether or not a box should float leftSets the left margin edge for a positioned box overflowSpecifies what happens if content overflows an element's box positionSpecifies the type of positioning for an element rightSets the right margin edge for a positioned box topSets the top margin edge for a positioned box visibilitySpecifies whether or not an element is visible z-indexSets the stack order of an element

Table properties PropertyDescription border-collapseSpecifies whether or not table borders should be collapsed border-spacingSpecifies the distance between the borders of adjacent cells caption-sideSpecifies the placement of a table caption empty-cellsSpecifies whether or not to display borders and background on empty cells in a table table-layoutSets the layout algorithm to be used for a table

Text properties PropertyDescription colorSets the color of text directionSpecifies the text direction/writing direction letter-spacingIncreases or decreases the space between characters in a text line-heightSets the line height text-alignSpecifies the horizontal alignment of text text-decorationSpecifies the decoration added to text text-indentSpecifies the indentation of the first line in a text-block text-shadowSpecifies the shadow effect added to text text-transformControls the capitalization of text vertical-alignSets the vertical alignment of an element white-spaceSpecifies how white-space inside an element is handled word-spacingIncreases or decreases the space between words in a text

Text CSS example h1 { color: #00ddee; text-align: justify; text-decoration: underline; text-shadow: 10; }

The CSS box model each HTML element is a “box” from CSS perspective; it has a margin, border, padding and content

The CSS Box model (2) Margin: clears an area around the border; does not have a background color, is completely transparent Border: lies around content and padding; has the background color of the box Padding: clears an area around the content; has the background color of the box Content: the actual content (text) of the box the height and width attributes do not specify the total height and width of the HTML element; they are calculated by: Total width=width+left padding+right padding+left border+ right border+left margin+right margin Total height=height+top padding+bottom padding+top border+ bottom border+top margin+bottom margin

Displaying and visibility hiding an element with consuming space: visibility: hidden; hiding an element without consuming space: display: none; html elements are displayed as: block – element takes the full width available and has a line break before and after it (e.g. h1, p, div) inline – element takes as much width as necessary and does not force line breaks (e.g. a, span) set the display mode with the display property ( e.g. display: inline; display: block ; ) make an image transparent: opacity: x – on Firefox, x between 0.0 and 1.0 filter:alpha(opacity=x) – on IE, x between 0 and 100.

Positioning static positioning: the default mode; a static element is positioned according to the normal flow of the page; fixed positioning: element will not move even if the window is scrolled ( position: fixed; top: 20px; right: 40px ); elements are removed from the normal flow and can overlap other elements relative positioning: element is positioned relative to its normal position; element can be moved and overlap other elements, but the reserved space form the element is preserved in the normal flow ( position: relative ) absolute positioning: element is positioned relative to the first parent element that has a position other then static (if none, ); elements are removed from the normal flow and can overlap other elements; ( position: absolute ) z-index property defines the stack order of an element

Floating with floating, an html element can be pushed left or right allowing other elements to wrap around it html elements can float horizontally left or right (not vertically) configured using the the float: left | right | none | inherit display property