User Tools

Site Tools


documentation:css

~~TOC~~

Lab46 Tutorials

CSS

Cascading Style Sheets

CSS was adopted in the mid 1990's as a way to standardize web pages. Style sheets can be used with many markup languages such as html, xml, svg and xul. It is used for defining the way a document looks. It accomplishes this by giving attributes (colors, fonts) to the tags in a markup language. Before style sheets all attributes had to be added to each tag individually. This can Be very inefficient for a site that has many pages. A style sheet allows an entire page or site to be standardized.

First Style Sheet

    p  {font-size: 50%; font-family: sans-serif;}
    h1 {color: red; font-weight: bold;}

save file as style.css

<html>
    <head>
        <style type= "text/css">
            @import "style.css";
        </style>
        <title>My New Web Page</title>
    </head>
    <body>
        <h1>Hello world</h1> 
        <p>
        this is my new web page!
        </p>
    </body>
</html>

save file as index.html

view in web browser

Common Attributes

  • background-color: <color>;
  • background-image: <url>;
  • font-family: <familyName>;
  • font-size: <size>;
  • font-weight: <weight>;
  • height: <length>;
  • margin: <length>;
  • padding: <length>;
  • text-align: <left|right|center>;
  • width: <length>;
documentation/css.txt · Last modified: 2010/05/20 08:01 by triley2