CSS Crash Course By Daniel D'Agostino First drafted: 19 th June 2007 Written on: 19 th October 2008.

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

Cascading Style Sheets
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.
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.
CSS(Cascading Style Sheets )
กระบวนวิชา 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 Controlling the Display Of Web Content.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Controlling Page Style: Cascading Style Sheets (CSS) References: 1.Wang, P.S & Katila, S. (2004). A Introduction to Web Design and Programming. CA: Thomson.
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
4.01 Cascading Style Sheets
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
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.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
 HTML stands for Hyper Text Mark-up Language. The coding language used to create documents for the World Wide Web  HTML is composed of tags. HTML tags.
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.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CO1552 – Web Application Development Cascading Style Sheets.
CSS Basic (cascading style sheets)
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
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 Cascading Style Sheets. CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate.
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.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
Cascading Style Sheets Level 2. Course Objectives, Session 1 Level 1 Quick Review Chapter 8: Adding Graphics to Web Pages Chapter 9: Sprucing Up Your.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
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.
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 Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Lecture 2: Cascading Style Sheets (CSS) Instructor: Dr. M. Anwar Hossain.
آموزش طراحی وب سایت جلسه پنجم– سی اس اس 2 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
Intro to CSS Christy. What is CSS?  Cascading Style Sheets  Separates content from presentation  Defines how to display HTML elements  Provides control.
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.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
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.
NAVIGATION USING HTML TO SET UP THE BASIC STRUCTURE OF A NAV BAR.
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
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 Sheets
Working with Cascading Style Sheets
Cascading Style Sheet.
4.01 Cascading Style Sheets
( Cascading style sheet )
CSS Layouts: Grouping Elements
Cascading Style Sheets
Cascading Style Sheets (Layout)
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Introduction to CSS.
Training & Development
Cascading Style Sheets (CSS)
Cascading Style sheet. What is CSS?  CSS stands for Cascading Style Sheets  Cascading: refers to the procedure that determines which style will apply.
4.01 Cascading Style Sheets
Presentation transcript:

CSS Crash Course By Daniel D'Agostino First drafted: 19 th June 2007 Written on: 19 th October 2008

Part 1 Introduction to CSS

What is CSS/Why CSS? A language complementary to HTML Separation of structure (HTML) and style (CSS) Centralisation of style in one file modifying one declaration can affect the whole site Allows allocating style to HTML elements defined by complex relationships e.g. A list in a list Note: Like HTML, different browsers interpret CSS differently

Links What can you do with CSS? Good reference material

Kickstart: The HTML side 1.Create a basic HTML file with, etc and some basic content to test with 2.Add the following to the section of your HTML page: Remember to close with /> if you are using XHTML!

Kickstart: The CSS side 1.Create an empty text file called style.css 2.Add the following in the CSS file: body { background-color:#FF0000; } Your page background should become red (equivalent to )

CSS Syntax explained body { background-color:#FF0000; } HTML element being designed property subproperty valueproperties of an element are listed between curly brackets

CSS Colours explained 3 types of colour values: hex values e.g. #FFFFFF shorthand: #xyz == #xxyyzz RGB values e.g. rgb(255, 255, 255) colour names e.g. white To set: foreground (text) colour use color: background colour use background-color:

More CSS examples background-color:#000000; color:#FFFFFF; text-decoration:underline; font-weight:bold; font-style:italic; margin-left:5px; padding-right:10%;

CSS property shorthand Consider: font-weight:bold; font-style:italic;...these are both subproperties of font. Shorthand equivalent: font: bold italic;

CSS Text Formatting Examples: color:black; font-weight:bold; font-style:italic; text-decoration:underline; text-align:center; font-family:Arial; font-size:18px; References:

About Fonts Try to use cross-platform fonts (e.g. Arial) so that site can look the same on different operating systems You can define a list of fonts to use... if the first one is not found, the next one in the list is used e.g. font-family: Verdana, Arial, Helvetica monospace is a family of fixed-width fonts serif vs sans-serif e.g. Times New Roman vs Arial

CSS Borders border left right top bottom width color style width color style width color style width color style

CSS Borders explained Define only one property of one border: border-bottom-width:3px; Define one border entirely: border: solid 2px #CC0000; Define one property of all borders: border-style:dashed; Define all properties of all borders: border: dotted 3px black;

Margins vs Padding abcde iiiivv iii Consider a table...

Margins vs Padding padding margin

CSS Margins and Padding Set individual margins: margin-left:2px; margin-right:4px; margin-top:3px; margin-bottom:5px; Set all margins: margin:5px; Set individual padding: padding-left:2px; padding-right:4px; padding-top:3px; padding-bottom:5px; Set all padding: padding:5px;

CSS Links a:link {...} unvisited link a:visited {...} visited link a:hover {...} mouseover link a:active {...} link with focus Reference:

Other useful CSS properties display (block, inline,...) visibility (visible, hidden,...) float overflow cursor list-style-type background (color, image, repeat) border-collapse (for tables)

CSS Complex Relationships p img {...} Applies to 's inside 's td, th, table {...} Applies to all of, and p.myclass {...} Applies to 's using the myclass class p#myid {...} Applies to 's using the myid id

CSS Complex Relationships Note: p#myid != p #myid (with space) p#myid -> all paragraphs defined as myid p #myid -> all elements defined as myid which are in a paragraph Elements with particular attributes: input[type=”text”] {...} limited browser support

CSS Inheritance If a property is not defined, its value is usually inherited from that of the parent (containing) element e.g. a paragraph may inherit the 's text colour A value can be explicitly inherited from the parent element using the inherit keyword e.g. color:inherit; useful when a property already has a value but we want to override it with an inherited value

Advanced CSS Further Reading Pseudo-classes Pseudo-elements Generated content

Part 2 CSS Techniques

HTML style attribute Can be used to use CSS directly in an HTML element e.g.... Useful for associating CSS with an HTML element that occurs only once (and which thus does not need to be defined in the external CSS file) Eliminates need for HTML layout tags/attributes in such situations

Internal Style Sheets For CSS to be used with only one HTML page...no need to use an external CSS file! Put the following in your section: <!-- /* CSS code goes here */ --> HTML comments are important for old non-CSS browsers to ignore the CSS Note: CSS comments are like in C++: /*... */

CSS Classes HTML side:... CSS side:.fancy {...} Applies properties of class.fancy to any HTML element that uses that class Classes begin with a dot

CSS IDs HTML side:... CSS side: #contents {...} Applies properties of class.fancy to any HTML element that uses that class IDs begin with a hash sign Unlike classes, IDs can be used only once in an HTML page

HTML 's HTML divisions are used to group several HTML elements together Useful to apply the same CSS to several elements at once Also useful to group elements structure-wise Commonly used to create divisions for navigation and content in the CSS layout

The CSS Layout: History HTML page layout evolved substantially over the years plain pages frames tables...and finally, CSS! Tables are ok but inadequate no logical relation between cells bloat page with presentation details maintenance nightmare

The CSS Layout: 's

CSS Positioning position:absolute; puts element in top-right corner regardless of other elements declared before or after it positioning properties: top:5px; left:10px; right:15px; bottom:20px;

The CSS Layout: How-To Using 's and CSS positioning properties, 's can be placed anywhere on the page This works great, and is used worldwide But... there is a better way! HTML lists can be used for navigation... even if it is horizontal (with display:inline) The HTML itself can be used for content

The Meaning of CSS CSS = Cascading Style Sheets Why Cascading? 1.style attribute 2.id attribute 3.class attribute 4.internal style sheet 5.external style sheet 6.default browser style setting CSS may be defined in various locations. Each of these has a priority. If a property is not defined in the highest priority location, the browser tries to find it in the next location.

CSS Media Different CSS can be applied to different CSS media Useful especially to make your website printer- friendly! Default media type is screen Support for media types is browser-dependent although CSS defines them

CSS Media Types screen print all aural braille embossed handheld projection tty tv Reference:

Example with Print print { #navigation { display:none; } #content { margin-left:0px; }

Multiple Style Sheets ● Use several 's to use multiple CSS files ● Use the title attribute to name them (for user selection)

Importing Style Sheets A style sheet can import properties from another style statements must occur before any other property url(”another.css”); Reference: