วิธีเปลี่ยนสีลิงค์ HTML
การเปลี่ยนสีลิงค์ทำได้ด้วยสไตล์ css:
<a href="../html-link.htm" style="color:red">Main page</a>
รหัสจะสร้างลิงค์นี้:
การเปลี่ยนสีพื้นหลังของลิงค์ทำได้ด้วยสไตล์ css:
<a href="../html-link.htm" style="background-color:#ffffa0">Main page</a>
รหัสจะสร้างลิงค์นี้:
รหัส CSS:
<style>
#link_bar a {
padding:15px; font-weight:bold; float:left; }
#link_bar a:link { color:#d0d0d0;
background-color:#0000a0; }
#link_bar a:visited { color:#c0c0c0;
background-color:#0000a0; }
#link_bar a:hover { color:#ffffff;
background-color:#000060; }
#link_bar a:active { color:#f0f0f0;
background-color:#00ff00; }
</style>
รหัส HTML:
<div id="link_bar">
<a
href="html-anchor-link.htm">Anchor link</a>
<a
href="html-link-color.htm">Link color</a>
<a
href="../mailto.htm">Email link</a>
<a
href="html-image-link.htm">Image link</a>
<a
href="html-text-link.htm">Text link</a>
</div>
ดู:
#link_bar aคือสไตล์สำหรับทุกสถานะของลิงก์
#link_bar a:linkคือรูปแบบของลิงก์ปกติ
#link_bar a:เยี่ยมชม เป็นรูปแบบของลิงค์ที่เยี่ยมชม
#link_bar a:hoverคือลักษณะของการเลื่อนเมาส์ไปที่ลิงก์
#link_bar a: active คือลักษณะของลิงค์เมื่อกดเมาส์
Advertising