標籤:
| |
| |
|
| |
css(層疊樣式表) 在一個網頁中主要負責了頁面的資料樣式。 |
| |
|
| |
編寫css代碼的方式: |
| |
|
| |
第一種: 在style標籤中編寫css代碼。 只能用於本頁面中,複用性不強。 |
| |
|
| |
格式 : |
| |
|
| |
<style type="text\css"> |
| |
編寫css的代碼。 |
| |
</style> |
| |
例子: |
| |
<style type="text\css"> |
| |
a{ |
| |
color:#F00; |
| |
text-decoration:none; |
| |
} |
| |
</style> |
| |
|
| |
第二種: 可以引入外部的css檔案。 推薦使用。 |
| |
|
| |
方式1: 使用link標籤。 推薦使用... |
| |
格式: |
| |
<link href="css檔案的路徑" rel="stylesheet"> |
| |
|
| |
例子: <link href="1.css" rel="stylesheet"/> |
| |
|
| |
方式2:使用<style>引入 |
| |
|
| |
格式: |
| |
<style type="text/css" > |
| |
@import url("css的路徑"); |
| |
</style> |
| |
|
| |
例子: |
| |
<style type="text/css" > |
| |
@import url("1.css"); |
| |
</style> |
| |
|
| |
第三種方式:直接在html標籤使用style屬性編寫。 只能用於本標籤中,複用性較差。 不推薦使用。 |
| |
|
| |
例子: |
| |
<a style="color:#0F0; text-decoration:none" href="#">新聞的標題1</a> |
<style type="text/css">/* html的注釋:<!-- html的注釋 --> css /* css的注釋 ..*/ /* */ </style>
<body> <h1>標題1</h1> <a style="color:#0F0; text-decoration:none" href="#">新聞的標題1</a> <a href="#">新聞標題2</a> <a href="#">新聞標題3</a> <a href="#">新聞標題4</a> <a href="#">新聞標題5</a> <a href="#">新聞標題6</a></body>
編寫css代碼的方式