CSS ???
CSS ???
Css ????
Id ? Class ???
? ?? ???? ????. HTML ???? CSS ???? ????? " id" ? "class" ???.
id ???
id ???? ?? ID? ??? HTML ??? ?? ?? ???? ??? ? ????.
HTML ??? id ??? ???? id ???? ???? CSS? id ???? "#"?? ?????.
?? ?? id="para1"? ?? ??? ??? ???? ???.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> #para1 { text-align:center; color:red; } </style> </head> <body> <p id="para1">php中文網(wǎng)(php.cn)</p> <p>這一段不受css樣式影響。</p> </body> </html>
????? ???? ??? ???
ID ??? ??? ???? ? ???. ??? ???? ID? ???? ????. ???/????? ????.
??? ???
??? ???? ?? ??? ???? ???? ? ?????. ??? ???? ?? ???? ??? ? ????.
??? ???? HTML? ??? ???? ?????. CSS??? ??? ???? ? "."?? ?????.
?? ???? ?? ???? ?? ?? HTML ??? ??? ?????.
?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> .center { text-align:center; } </style> </head> <body> <h1 class="center">標(biāo)題居中</h1> <p class="center">段落居中。</p> </body> </html>
????? ???? ??? ???
???? ???? ?? HTML ??? ??? ?? ????.
?? ??? ?? p ??? class="center"? ???? ??? ???? ??? ?????.
Example
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> p.center { text-align:center; } </style> </head> <body> <h1 class="center">這個(gè)標(biāo)題將不會(huì)受到影響</h1> <p class="center">這一段將居中對(duì)齊</p> </body> </html>
????? ???? ??? ???
???? ? ?? ?? ??? ??? ??? ? ????! Mozilla? Firefox??? ???? ????.