Layout (CSS)Cascading Style Sheets
What is CSS?CSS stands for Cascading Style SheetsStyles define how to display HTML elementsStyles were added to HTML 4.0 to solve a problemExternal Style Sheets can save a lot of workExternal Style Sheets are stored in CSS files
CSS Saves a Lot of Work!CSS defines HOW HTML elements are to be displayed.Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!
CSS SyntaxA CSS rule has two main parts: a selector, and one or more declarations:The selector is normally the HTML element you want to style.Each declaration consists of a property and a value.The property is the style attribute you want to change. Each property has a value.
CSS CommentsComments are used to explain your code, and may help you when you edit the source code at a later date. Comments are ignored by browsers.A CSS comment begins with "/*", and ends with "*/", like this:/*This is a comment*/p{text-align:center;/*This is another comment*/color:black;font-family:arial;}
CSS is the better half of HTML. And in coding, there is no equality of status: HTML takes care of the rough stuff (the structure), while CSS gives it a nice touch (layout).
One of the smart features of CSS is the possibility to manage your layout centrally. Instead of using the style attribute in each tag, you can tell the browser once how it must layout all the text on the page:
<html> <head> <title>My first CSS page</title>	<style type="text/css">	h1 {font-size: 30px; font-family: arial;}	h2 {font-size: 15px; font-family: courier;}	p {font-size: 8px; font-family: "times new roman";} </style></head> <body> <h1>My first CSS page</h1> <h2>Welcome to my first CSS page</h2><p>Here you can see how CSS works </p></body> </html>
What else can I do with CSS?CSS can be used for much more than specifying font types and sizes. For example, you can add colours and backgrounds. Here are some examples for you to experiment with.
<p style="color:green;">Green text</p> <h1 style="background-color: blue;">Heading on blue background</h1> <body style="background-image: url('http://www.html.net/logo.png');">
Is CSS nothing but colours and font types?CSS can also be used to control the page setup and presentation (margins, float, alignment, width, height etc.). By regulating the different elements with CSS you are able to layout your pages elegantly and precisely.
<p style="padding:25px;border:1px solid red;">I love CSS</p>ResultI Love CSS
With the property float an element can either be floated to the right or to the left.<imgsrc="bill.jpg" alt="Bill Gates" style= "float:left;" /> <p>Loremipsumdolor sit amet, consectetueradipiscingelit, seddiamnonummynibheuismodtinciduntutlaoreetdolore magna aliquameratvolutpat. Utwisienim ad minim veniam, quisnostrudexercitationullamcorpersuscipitlobortisnislutaliquip ex ea commodoconsequat...</p>
Css intro

Css intro

  • 1.
  • 2.
    What is CSS?CSSstands for Cascading Style SheetsStyles define how to display HTML elementsStyles were added to HTML 4.0 to solve a problemExternal Style Sheets can save a lot of workExternal Style Sheets are stored in CSS files
  • 3.
    CSS Saves aLot of Work!CSS defines HOW HTML elements are to be displayed.Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!
  • 4.
    CSS SyntaxA CSSrule has two main parts: a selector, and one or more declarations:The selector is normally the HTML element you want to style.Each declaration consists of a property and a value.The property is the style attribute you want to change. Each property has a value.
  • 5.
    CSS CommentsComments areused to explain your code, and may help you when you edit the source code at a later date. Comments are ignored by browsers.A CSS comment begins with "/*", and ends with "*/", like this:/*This is a comment*/p{text-align:center;/*This is another comment*/color:black;font-family:arial;}
  • 6.
    CSS is thebetter half of HTML. And in coding, there is no equality of status: HTML takes care of the rough stuff (the structure), while CSS gives it a nice touch (layout).
  • 7.
    One of thesmart features of CSS is the possibility to manage your layout centrally. Instead of using the style attribute in each tag, you can tell the browser once how it must layout all the text on the page:
  • 8.
    <html> <head> <title>Myfirst CSS page</title> <style type="text/css"> h1 {font-size: 30px; font-family: arial;} h2 {font-size: 15px; font-family: courier;} p {font-size: 8px; font-family: "times new roman";} </style></head> <body> <h1>My first CSS page</h1> <h2>Welcome to my first CSS page</h2><p>Here you can see how CSS works </p></body> </html>
  • 9.
    What else canI do with CSS?CSS can be used for much more than specifying font types and sizes. For example, you can add colours and backgrounds. Here are some examples for you to experiment with.
  • 10.
    <p style="color:green;">Green text</p><h1 style="background-color: blue;">Heading on blue background</h1> <body style="background-image: url('http://www.html.net/logo.png');">
  • 11.
    Is CSS nothingbut colours and font types?CSS can also be used to control the page setup and presentation (margins, float, alignment, width, height etc.). By regulating the different elements with CSS you are able to layout your pages elegantly and precisely.
  • 12.
    <p style="padding:25px;border:1px solidred;">I love CSS</p>ResultI Love CSS
  • 13.
    With the propertyfloat an element can either be floated to the right or to the left.<imgsrc="bill.jpg" alt="Bill Gates" style= "float:left;" /> <p>Loremipsumdolor sit amet, consectetueradipiscingelit, seddiamnonummynibheuismodtinciduntutlaoreetdolore magna aliquameratvolutpat. Utwisienim ad minim veniam, quisnostrudexercitationullamcorpersuscipitlobortisnislutaliquip ex ea commodoconsequat...</p>