close


支援CSS2 以上

用法:p[id=名稱]
說明:套用有定義id屬性的p tag 等於 某名稱

css定義:
p[id=p1] {
文字大小 font-size : 30px 為30像素
文字顏色 color :color 為 blue;
}
注意事項:
p[id="p1"]跟p[id=p1] 都是可以的。

程式:
<!DOCTYPE html>
<html>
<head>
<title>css基本定義 [attribute=value]元素屬性 套用樣式</title>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<style type="text/css">

p[id=p1] {
font-size: 30px;
color: blue;
}

</style>
</head>
<body>
<p id="p1">p Tag id=p1</p>

<div>
  <span><p>div span p Tag</p></span>
</div>
<p id="p2"> p Tag id=p2</p>

<span>
<h5 id="myDivId">span h5 Tag myDivId</h5>
<p>span p Tag</p>
</span>
<ul>
<li><p> ul li p Tag</p></li>
<li><p> ul li p Tag</p></li>
<li><p> ul li p Tag</p></li>
</ul>
<p id="p3"> p Tag id=p3</p>

<div>
<h5> h5 Tag</h5>
<p>p Tag</p>
</div>

<p id="p4"> p Tag id=p4</p>
</body>
</html>



圖:





測試結束~
如果還不了解可參考:w3schools CSS Selector Reference

感謝~





 






 















其它文章

arrow
arrow

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()