โดยใช้ CSS pseudo selectors ได้แก่ :active, :hover, :link และ :visited เราสามารถจัดรูปแบบสถานะต่างๆ ของลิงก์ได้ สำหรับการทำงานที่ถูกต้อง ลำดับของตัวเลือกเหล่านี้คือ: :link, :visited, :hover, :active
ไวยากรณ์
ไวยากรณ์ของคุณสมบัติ CSS text-indent ดังนี้:
a:(pseudo-selector) { /*declarations*/ }
ตัวอย่าง
ตัวอย่างต่อไปนี้แสดงการจัดรูปแบบสถานะต่างๆ ของลิงก์:
<!DOCTYPE html> <html> <head> <style> div { margin-left: 20px; display: flex; float: left; } a:link { color: navy; text-decoration: none; } a:visited { color: yellowgreen; } a:hover { color: orange; text-decoration: wavy underline; } a:active { color: red; } </style> </head> <body> <div> <div> <a href="#">Demo link </a> </div> <div> <a href="">Demo visited link</a> </div> </div> </body> </html>
ผลลัพธ์
ได้ผลลัพธ์ดังนี้:

เมื่อวางเมาส์บนลิงก์แรก ได้ผลลัพธ์ดังนี้:

ขณะคลิกลิงก์ที่สอง ได้ผลลัพธ์ดังนี้:

ตัวอย่างเพิ่มเติม
<!DOCTYPE html> <html> <head> <style> div { display: flex; float: left; } a { margin: 20px; padding: 10px; border: 2px solid black; text-shadow: -1px 0px black, 0px -1px black, 0px 1px black, 1px 0px black; font-size: 1.1em; } a:link { text-decoration: none; } a:visited { color: blueviolet; } a:hover { color: orange; font-size: 150%; font-weight: bold; box-shadow: 0 0 5px 1px grey; } a:active { color: red; box-shadow: inset 0 0 15px red; } </style> </head> <body> <div> <a href="#">Kapow!</a> <a href="">Dishoom</a> </div> </body> </html>
ผลลัพธ์
ได้ผลลัพธ์ดังนี้:

เมื่อวางเมาส์บนลิงก์แรก ได้ผลลัพธ์ดังนี้:

ระหว่างการคลิกลิงก์แรก ผลลัพธ์ต่อไปนี้จะถูกส่งคืน:
