Thuộc tính:default selector dùng để thiết lập phần tử mặc định trong một nhóm các phần tử cùng loại. Default selector được dùng trên button, option, radio button và check-box.
Cú pháp:
:default {
//property
}
Ví dụ:
HTML<!DOCTYPE html>
<html>
<head>
<style>
input[type="checkbox"]:default {
box-shadow: 0 0 1px 1px gray;
}
</style>
</head>
<body>
<h3>Select Language</h3>
<form action="">
<input type="checkbox" name="lan" value="c" checked> C
<br>
<input type="checkbox" name="lan" value="c++"> C++
<br>
<input type="checkbox" name="lan" value="java"> Java
<br>
<input type="checkbox" name="lan" value="c#"> C#
<br>
<input type="checkbox" name="lan" value="python"> Python
<br>
<input type="checkbox" name="lan" value="javascript"> JavaScript
<br>
</form>
</body>
</html>
Kết quả:
Trình duyệt được hỗ trợ:
- Google Chrome 10.0
- Edge 79.0
- Firefox 4.0
- Safari 5.0
- Opera 10.0