IT581: Practicum in Web Development, Summer 2015 (Hybrid)

Cascading Style Sheets (CSS) Basics and Typography

Structure and Presentation


Properties

element

Defaults


Values


Benefits of Stylesheets

Style Sheets define specifications that can control the presentation of the rendered documents.

They do not affect the contents of the document, only the appearance (or equivalent). With style sheets,


Style Sheet capabilities

Styles let you


Incorporating styles


Placement of an embedded stylesheet

  <head>

    <title>Document title here</title>

    <style type="text/css">
        Style rules go in here.
    </style>

  </head>

Style Rules


Color styles


Color Values


RGB Color Values


Example 1: background and foreground colors

    <style type="text/css">
        body {background-color: #ffff00;
              color: red}
    </style>

Link to a complete example 1 page illustrating colors.


Cascading rules


Example 2. the cascading effect

    <style type="text/css">
        body {background-color: #ffff00;
              color: red}
        h1 {background-color: #889999;
            color: black}
        p {background-color: #ffffff;
           color: black}
        em {background-color: maroon;
            color: #ffff00 }}
     </style>
 

Link to a complete example 2 page illustrating the cascading effect.


Style properties for fonts


Typefacestype face

Serif and sans-serif typefaces

Proportional and monospace fonts


Specifying font-families

Example 3.

    <style type="text/css">
        body {font-family: "Verdana"}
        h1 {font-family: "Comic Sans MS"}
        h2 {font-family: "Comic Sans MS"}
        strong {font-family: "Courier"}
     </style>
 

Link to a complete example 3 page illustrating font-families.


Alternative typefaces


Font size

type face


font-weight and font-style


Example 5.

    <style type="text/css">
        body {font-weight: bold}
        h1 {font-weight: normal}
        h2 {font-weight: normal}
        strong {font-weight: normal;
                font-style: italic}
     </style>
 

Link to a complete example 5 page illustrating font-weight and font-style.


Text alignmenttext alignment


Example 6.

    <style type="text/css">
        body {text-align: justify}
        h1 {text-align: center}
        h2 {text-align: right}
     </style>
 

Link to a complete example 6 page illustrating text-align


Margins


Example 7.

    <style type="text/css">
        body {margin-top: 15px;
              margin-right: 25px;
              margin-bottom: 15px;
              margin-left: 100px;
        }
        h1 {margin-left: -50px}
        h2 {margin-left: 50px}
     </style>
 

Link to a complete example 7 page illustrating margins


Block height and width


Example 8

    <style type="text/css">
        h1 {width: 40%;
            background-color: silver}
        h2 {height: 100px;
            width: 150px;
            background-color: yellow}
        p {background-color: #ffddff}
    </style>

Link to a complete example 8 page illustrating block height and width


Centering a block


Example

    <style type="text/css">
        h1 {width: 50%;
            background: yellow;
            margin-left: auto;
            margin-right: auto;}

        h2 {background-color: #ccffff;
            text-align: center;
            width: 75%}

        p {width: 620px;
           background: silver;
           margin-left: auto;
           margin-right: auto;
           text-align: center;}
    </style>

Link to a complete example 9 page illustrating centering blocks


Example 10: multiple rules

    <style type="text/css">
        body { background-color: #ffff00;
               color: maroon;
               font-family: Verdana, Arial,Helvetica,sans-serif;
               font-size: small;
               text-align: justify;
               margin: 20px }

        h1 { background-color: #00ffff;
             color: red;
             font-family: Georgia, 'Times New Roman', Times, serif;
             font-size: 200%;
             text-align: center;
             width: 50%;
             margin-left: auto;
             margin-right: auto; }

        h2 { text-align: right;
             background: #ffffcc;
             width: 50%; }

        p {background-color: #ffffff;
           color: teal;
           margin-right: 100px;
           margin-left: 50px;}

        strong { background-color: silver; color: black;
                 font-family: 'Courier New', Courier, monospace;
                 font-size: large;
                 font-weight: normal }
    </style>

Link to a complete example 10 page illustrating multiple style properties in one document


Design Guidelines

We will discuss design issues intermittently throughout the course. For now, keep in mind the following guidelines.

Comments to: dong@hood.edu
Last Modified: 06 July 2015. 19:20