Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

บทบาทของ CSS :visited Selector

ใช้ :visited เพื่อจัดสไตล์ Link ที่เคยถูกเยี่ยมชมแล้ว

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
    <style>
        a:link, a:visited {
            background-color: white;
            color: black;
            border: 1px solid blue;
            padding: 30px 30px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
        }
        a:hover, a:active {
            background-color: red;
            color: white;
        }
    </style>
</head>
<body>
    <a href="demo.html" target="_blank">Demo Link</a>
</body>
</html>

ข้อจำกัดด้านความปลอดภัย: Browser จำกัด CSS Properties ที่ใช้กับ :visited ได้เฉพาะ Color-related (color, background-color, border-color, outline-color) เพื่อป้องกัน History Sniffing

ลำดับ LVHA: :link → :visited → :hover → :active