CSS 可以通過以下方式添加到HTML中:
內(nèi)聯(lián)樣式- 在HTML元素中使用"style" 屬性
內(nèi)部樣式表 -在HTML文檔頭部 <head> 區(qū)域使用<style> 元素 來包含CSS
外部引用 - 使用外部 CSS 文件
最好的方式是通過外部引用CSS文件
我們可以使用font-family(字體)十饥,color(顏色),和font-size(字體大凶嫒椤)屬性來定義字體的樣式:
1.<style type="text/css">
h1 {color:red;}
p {color:yellow;}
</style>
<body style="font-family:arial;color:red;font-size:20px;">
<h1>大標(biāo)題</h1>
</body>
3.文本對齊方式text-align
<h1 style="text-align:center">標(biāo)題居中</h1>
4.外部樣式表
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
圖像
<img src="url" alt="文字描述" width="??" height="??" >
<img> 是空標(biāo)簽逗堵,意思是說,它只包含屬性眷昆,并且沒有閉合標(biāo)簽蜒秤。
要在頁面上顯示圖像汁咏,你需要使用源屬性(src)。src 指 "source"作媚。源屬性的值是圖像的 URL 地址攘滩。
定義圖像的語法是:
<img src="url" alt="some_text">
URL 指存儲(chǔ)圖像的位置。如果名為 "pulpit.jpg" 的圖像位于 www.runoob.com 的 images 目錄中纸泡,那么其 URL 為http://www.runoob.com/images/pulpit.jpg漂问。
注意: 加載頁面時(shí),要注意插入頁面圖像的路徑弟灼,如果不能正確設(shè)置圖像的位置级解,瀏覽器無法加載圖片,圖像標(biāo)簽就會(huì)顯示一個(gè)破碎的圖片
圖像映射
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
該段代碼中的shape指的是點(diǎn)擊區(qū)域的形狀田绑,coords指的應(yīng)該是鏈接區(qū)域在圖片中的坐標(biāo)(像素為單位)
1勤哗、矩形:(左上角頂點(diǎn)坐標(biāo)為(x1,y1),右下角頂點(diǎn)坐標(biāo)為(x2,y2))
<area shape="rect" coords="x1,y1,x2,y2" href=url>
2掩驱、圓形:(圓心坐標(biāo)為(X1,y1)芒划,半徑為r)
<area shape="circle" coords="x1,y1,r" href=url>
3、多邊形:(各頂點(diǎn)坐標(biāo)依次為(x1,y1)欧穴、(x2,y2)民逼、(x3,y3) ......)
<area shape="poly" coords="x1,y1,x2,y2 ......" href=url>