Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Cách chọn phần tử có thuộc tính và giá trị xác định với CSS

Sử dụng bộ chọn [attribute="value"] để chọn các phần tử có thuộc tính và giá trị xác định.

Ví dụ

Bạn có thể chạy mã sau để triển khai bộ chọn CSS [attribute="value"]. Ở đây, chúng ta xem xét thuộc tính là rel:

<!DOCTYPE html>
<html>
  <head>
    <style>
      a[rel="nofollow"] {
        border: 3px solid blue;
      }
    </style>
  </head>
  <body>
    <a href="https://qries.com/What-is-Uber-s-business-model-and-how-does-it-compare-with-Ola-s-model-in-India" rel="nofollow">Mô hình kinh doanh Uber</a><br><br>
    <a href="https://www.qries.com/How-does-share-market-work-in-India" rel="noreferrer">Chứng khoán</a>
  </body>
</html>