spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / easy_css / 1 current pageTo page 2
[next]

CSS: Cascading Style Sheets Made Easy

ASP 3.0/.NET Developer
Jupitermedia
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Biz Resources
Contact Management Software
Domain Name Services
Internet Security
Developer News
Apple Details iPhone-Mac Developer Event
RIM Ups Ante With Mobile Software Push
Novell Readies Silverlight Clone for Linux

By Taylor Anderson

HTML was originally intended to be used to define the content of a document using tags such as <h1>, <p>, <table> and the browser was to take care of the layout without the use of formatting tags like <font>. As the major browsers (Internet Explorer and Netscape) continued to support more tags it became very difficult to create Web sites where the content was separated from the presentation layout. In other words, the design and content became intertwined making it difficult to make changes. The W3 (World Wide Web Consortium) created styles in response. Most modern browsers now support CSS so it’s safe and easy to use. CSS can save you a lot of work when designing a website. Instead of having the same styles in the <head> tags you can have an external style sheet to control the layout and styles of the whole website. This means you can change many elements of the entire website by changing one file!

Using CSS: Where?

There are two ways to define styles using CSS. The best way is generally to use an external CSS file so that you can control many different elements throughout the entire site instead of defining the same elements over and over in all of the HTML files.

To make use of CSS, insert the following code between the opening <head> tag and the closing </head> tag.

         <link rel="stylesheet" type="text/css" href="path/to/stylesheet" />

Simply insert that between the <head></head> tags in a HTML document.

NOTE: For “path/to/stylesheet” insert the path from the HTML file you are editing to the CSS page.

The second way is to insert <style></style> tags in the head tags. This is a good way to define styles you only use on one page; otherwise you will want to use an external file sheet for two big reasons: Visitors only have to load the sheet once, and you can control the styles for the entire site by editing one page.

Formatting Text

Using CSS for formatting text is much easier than using <font> tags everywhere! Let’s start formatting text!

Open Notepad or favorite HTML editor, where you can copy and paste the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<h1>CSS: Cascading Style Sheets</h1>
<p>I love CSS, its so easy to use and it makes changes much easier! I can do things in CSS that HTML can’t!</p>
</body>
</html>

Personally, I use XHTML for every type of website now because it’s cleaner and more precise that HTML 4.01. After you’ve inserted the above code, save the file as index.html

Open a new notepad document and write the following.

Figure 1-1

If you want to insert a comment:

/* Any text placed here will be ignored
You
Can
Have
Spaces
Too*/

When you’re done, save the file as style.css and open the index.html file again.


home / programming / easy_css / 1 current pageTo page 2
[next]



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Software Engineering for Ajax - Part 2 · How to Create an Ajax Autocomplete Text Field: Part 6 · Software Engineering for Ajax
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
May Newsbits · Corsair Claims DDR3 Frequency Record at 2462MHz · Moli.Com: Social Networking Means Business

Created: March 27, 2003
Revised: February 2, 2005

URL: http://webreference.com/programming/easy_css/1