How do I put a style sheet into a separate file?

An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below: you start first by creating an empty text file in Notepad or a text editor.

Then cut and paste everything that is inside the <style> element from the HTML file into the new text file. The <style> tags belong to HTML, not to CSS; hence we must not copy them. Here is how the text doc will look for example:

body {
  font-family: Georgia, "Times New Roman",Times, serif;
  color: purple;
  background-color: #d8da3d }
h1 {
  font-family: Helvetica, Geneva, Arial,
  SunSans-Regular, sans-serif}
a:link {
  color: blue }
a:visited {
  color: purple }


Choose “Save As…” from the File menu; make sure that you are in the same directory/folder as the mypage.html file, and save the style sheet as “mystyle.css”.

Back

 
Printer friendly version of the CSS-FAQ-Separate-File-Style-Sheet page


Sponsored links

ASP.NET 3.5 Hosting on Windows 2008!
ASP.NET 3.5/2.0 Hosting on Windows 2008 & 2003! AJAX, LINQ, & Silverlight Ready! 3 Mo. Free!!
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
Experience Adobe? FLASH MEDIA SERVER 3
Introducing the media solution for total action without interruption. TRY IT NOW FOR FREE!

Advertisement



Free Magazine

Free Magazines
eWeek The essential technology information source for builders of e-business.... subscribe now

Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.