HTMLのカラースタイルを設定する5つの方法

方法 1. 埋め込みスタイルシート

<style>
h1 {
      
      color: pink;}
</style>
<h1>The color is pink!</h1>

方法 2、インライン スタイル

<h1 style="color: gold;">The color is gold!</p>

方法 3: ID またはクラスを使用して導入する

<style>
.grn {
      
      color: green;}
</style>
<h1 id="grn">The color is green!</h1>

方法4. 外部スタイルシート

<link rel="stylesheet" href="./style.css">
<h1>The color is orange!</h1>

スタイル.css

h1 {color: orange;}

方法5. スタイルシートをインポートする

<link rel="stylesheet" href="./style.css">
<h1>The color is white!</h1>

スタイル.css

@import "1.css";
@import "2.css";

1.css

h1 {color: white;}

おすすめ

転載: blog.csdn.net/weixin_46119529/article/details/130953139