css樣式引入的三個層級

來源:互聯網
上載者:User
1.屬性引入: 在標籤中添加style屬性,僅適用於當前標籤

2.<style>標籤引入: 在當前頁面中使用<style>標籤引入,僅適用於當前文檔

3.<link>標籤引入: 引用外部的CSS樣式表檔案,適用於所有引入該檔案的文檔

三種方式各有用途,根據需求來使用,不過,除非情況特殊,否則儘可能的使用外部樣式表

<!DOCTYPE html><html><head><meta charset="UTF-8"><link rel="stylesheet" type="text/css" href="./css/demo.css"><link rel="stylesheet" type="text/css" href="./css/demo.php"><title>css樣式引入的三個層級</title><style type="text/css">h3  {background-color: lightcyan;color: blue;}</style></head><body><h3 style="color: green">這是一個悲傷的故事</h3></body></html>
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.