- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>通高科技</title>
- <style>
- .p1{
- color: green;
- }
- </style>
- </head>
- <body>
- <p >這是屬性<span class="p1">小寫</span></p>
- </body>
- </html>
雙引號(hào)是最常用的,單引號(hào)也沒(méi)有問(wèn)題,不過(guò)遇到特殊情況,屬性值里面已經(jīng)有雙引號(hào)例:name='Bill "HelloWorld" ',這時(shí)候我們就的使用單引號(hào)了,要不就會(huì)報(bào)語(yǔ)法錯(cuò)誤提示,
大小寫都可以,屬性和屬性值對(duì)大小寫不敏感。瀏覽器都能夠識(shí)別,不過(guò)萬(wàn)維網(wǎng)在 HTML4時(shí)推薦使用小寫,示例:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>通高科技</title>
- <style>
- .p1{
- color: green;
- }
- </style>
- </head>
- <body>
- <p class="p1">這是屬性小寫</p>
- <p CLASS="p1">這是屬性大寫</p>
- </body>
- </html>
屬性總是以(名稱:值)的固定形式出現(xiàn),比如:alt="通高科技"。屬性出現(xiàn)格式:開(kāi)始標(biāo)簽中 ;例
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=yes">
- <title>通高科技</title>
- </head>
- <body>
- <img alt='通高科技' src='...' />
- </body>
- </html>