SunQuest
 
       Style Sheets
  Home arrow Style Sheets arrow Page 3 - Modifying the Look and Feel of Individual ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Modifying the Look and Feel of Individual Elements with Multiple Style Sheets
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 3
    2007-09-17

    Table of Contents:
  • Modifying the Look and Feel of Individual Elements with Multiple Style Sheets
  • Swapping entire persistent style sheets
  • Developing a simple CSS class-level application
  • Changing the style of DIVs and paragraphs

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Modifying the Look and Feel of Individual Elements with Multiple Style Sheets - Developing a simple CSS class-level application


    (Page 3 of 4 )

    According to the concepts that I deployed in the introduction to this final article of the series, my intention here is to show you yet another approach which will come in handy for changing the style of individual elements of a given web page, but without swapping complete style sheets.

    First I will use the same set of style sheets that were created in the previous article, whose definitions looked like this:

    (definition for "red.css" file)

    .red{
      background: #f00;
    }

    (definition for "green.css" file)

    .green{
      background: #0f0;
    }

    (definition for "blue.css" file)

    .blue{
      background: #00f;
    }

    (definition for "fontsize1.css" file)

    .size1{
      font: normal 14pt Arial, Helvetica, sans-serif;
    }

    (definition for "fontsize2.css" file)

    .size2{
      font: normal 18pt Arial, Helvetica, sans-serif;
    }

    (definition for "fontsize3.css" file)

    .size3{
      font: normal 24pt Arial, Helvetica, sans-serif;
    }

    As you can see, the CSS files defined above should be quite familiar to you, since I used them with some practical examples developed in previous tutorials of the series. Thus, having defined this group of CSS style sheets, the next step consists of defining a sample (X)HTML file that loads the CSS files.

    This brand new file looks like this: 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-
    8859-1" />
    <title>Multiple style sheets</title>
    <link rel="stylesheet" type="text/css" href="default.css" />
    <link rel="stylesheet" type="text/css" href="red.css" />
    <link rel="stylesheet" type="text/css" href="green.css" />
    <link rel="stylesheet" type="text/css" href="blue.css" />
    <link rel="stylesheet" type="text/css" href="fontsize1.css" />
    <link rel="stylesheet" type="text/css" href="fontsize2.css" />
    <link rel="stylesheet" type="text/css" href="fontsize3.css" />
    </head>
    <body>
     
    <h1>Changing the style of web page elements</h1>
     
    <div id="content">
       
    <p id="par">This is the content of the DIV.</p>
     
    </div>
     
    <a href="">Red</a>&nbsp;<a href="">Green</a>&nbsp;<a
    href="">Blue</a>&nbsp;<a href="">Font Size 1</a>&nbsp;<a
    href="">Font Size 2</a>&nbsp;<a href="">Font Size 3</a>&nbsp;<a
    href="">Reset Styles</a>
    </body>
    </html>

    As shown previously, the structure of the above (X)HTML file is extremely basic. It includes only one DIV and a paragraph, identified as "content" and "par" respectively. Quite simple to grasp, right?

    Now, based upon the signature of the prior web document, in the next section I will define a basic JavaScript function. It will use the CSS classes defined in the different style sheets that you learned before to modify the visual appearance of the mentioned DIV and the paragraph as well.

    To see how this process will be performed, go ahead and read the last section of this tutorial. We're almost done!

    More Style Sheets Articles
    More By Alejandro Gervasio


       · In this last installment of this series, you’ll learn how to use JavaScript to...
     

    STYLE SHEETS ARTICLES

    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables
    - CSS: Working with Text
    - CSS: Backgrounds
    - CSS for the Newbie


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway