html如何給h標簽添加顏色?
網(wǎng)友解答: 兩種方式,一種<h加樣式,另一種結(jié)合<font元素,但不常用,如下面例子<!DOCTYPE html<html <body <h1
兩種方式,一種<h加樣式,另一種結(jié)合<font元素,但不常用,如下面例子
<!DOCTYPE html
<html
<body
<h1 style="color:blue "Hello World</h1
<h2<font color="green"Hello World</font</h2
</body
</html
運用結(jié)果如下
網(wǎng)友解答:4種方法。
一:行內(nèi)樣式
直接在標簽里添加。<h1 style=“color:red”content</h1 這樣子h標簽里的文字就變成了紅色。
二:使用style標簽
直接在html頁面里嵌入style標簽,通過選擇器獲取到h標簽,之后再添加樣式。
<head
<style
#title{color:red}
</style
</head
<h1 id=”title“content</h1
三:通過引入CSS文件
外部CSS樣式
#title{color:red} 文件名為style.css
引入:
<head<link rel=“stylesheet/css” href=“style.css”</head
<h1 id=”title“content</h1
四:通過js來動態(tài)添加
<h1 id=”title“content</h1
<script
document.getElementById(“title”).style.color = “red”;
</script