Use External CSS

Quoted from http://www.tizag.com/cssT/external.php


What's external CSS

When using CSS it is preferable to keep the CSS separate from your HTML. Placing CSS in a separate file allows the web designer to completely differentiate between content (HTML) and design (CSS). External CSS is a file that contains only CSS code and is saved with a ".css" file extension. This CSS file is then referenced in your HTML using the <link> instead of <style>. If you're confused, don't worry. We are going to walk you through the whole process.

Example

This is a html file named index.html:

 1  < html >
 2  < head >
 3  < link  rel ="stylesheet"  type ="text/css"  href ="test.css"   />
 4  </ head >
 5  < body >
 6  < h3 >  A White Header  </ h3 >
 7  < p >  This paragraph has a blue font.  
 8  The background color of this page is gray because
 9  we changed it with CSS!  </ p >
10  </ body >
11  </ html >

Make sure save this file as "index.html" (without the quotes) in the same directory as your CSS file.

Why use external CSS file?

  1. It keeps your website design and content separate.
  2. It's much easier to reuse your CSS code if you have it in a separate file. Instead of typing the same CSS code on every web page you have, simply have many pages refer to a single CSS file with the "link" tag.
  3. You can make drastic changes to your web pages with just a few changes in a single CSS file.

转载于:https://www.cnblogs.com/suchangyu/archive/2009/09/03/1559301.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值