Liên kết có thể được tạo kiểu với bất kỳ thuộc tính CSS nào, chẳng hạn như
color: black;
text-decoration: none;
56, color: black;
text-decoration: none;
57, color: black;
text-decoration: none;
58 và color: black;
text-decoration: none;
59. Đây là một ví dụ dễ dànga {
color: hotpink;
}
Ngoài ra, các liên kết có thể được tạo kiểu khác nhau tùy thuộc vào trạng thái của chúng
Liên kết cũng có 4 trạng thái và nhiều lập trình viên tạo kiểu cho mỗi trạng thái khác nhau. Bốn trạng thái là
60. một liên kết chưa được truy cập, chưa được nhấpcolor: black; text-decoration: none;
61. một liên kết được truy cập, nhấp vàocolor: black; text-decoration: none;
0. một liên kết khi con chuột của người dùng ở trên nócolor: black; text-decoration: none;
1. một liên kết khi nó được nhấp vàocolor: black; text-decoration: none;
Thuộc tính
color: black;
text-decoration: none;
2 chịu trách nhiệm tạo URL và có thể được sửa đổi bằng cách sử dụng một số thuộc tính tạo kiểu CSS, mặc dù nó có một vài thuộc tính theo mặc định- gạch dưới
- Màu xanh da trời
Bạn có thể thay đổi những điều này bằng cách thêm thay đổi thuộc tính
color: black;
text-decoration: none;
56 và color: black;
text-decoration: none;
4 color: black;
text-decoration: none;
Bạn cũng có thể tạo kiểu cho liên kết dựa trên tương tác bằng các thuộc tính này, còn được gọi là trạng thái liên kết
- a. liên kết - một liên kết bình thường, chưa được truy cập
- a. đã truy cập - một liên kết mà người dùng đã truy cập
- a. hover - một liên kết khi người dùng di chuột qua nó
- a. hoạt động - một liên kết ngay khi nó được nhấp vào
Đây là một số CSS mẫu sử dụng 4 trạng thái
a:link { color: red; }
a:visited { color: blue; }
a:hover { color: green; }
a:active { color: blue; }
Lưu ý rằng có một số quy tắc đặt hàng khi bạn đặt kiểu cho trạng thái liên kết
0 PHẢI đến saucolor: black; text-decoration: none;
60 vàcolor: black; text-decoration: none;
61color: black; text-decoration: none;
color: black;
text-decoration: none;
1 PHẢI đến sau color: black;
text-decoration: none;
0a. liên kết - một liên kết bình thường, chưa được truy cập a. đã truy cập - một liên kết mà người dùng đã truy cập. hover - một liên kết khi người dùng di chuột qua nó. hoạt động - một liên kết ngay khi nó được nhấp vào
color: black;
text-decoration: none;
0Tìm hiểu thêm về kiểu dáng trong CSS
- Cách tạo kiểu thẻ HTML trực tiếp trong CSS
- Cách tạo kiểu danh sách bằng CSS
- Cách tạo kiểu nút bằng CSS
QUẢNG CÁO
QUẢNG CÁO
Nếu bài viết này hữu ích, hãy tweet nó
Học cách viết mã miễn phí. Chương trình giảng dạy mã nguồn mở của freeCodeCamp đã giúp hơn 40.000 người có được việc làm với tư cách là nhà phát triển. Bắt đầu
CSS. liên kết
Cải thiện bài viết
Lưu bài viết
Thích bài viết
- Độ khó. Dễ dàng
- Cập nhật lần cuối. 19 tháng 1 năm 2022
Cải thiện bài viết
Lưu bài viết
Liên kết là kết nối từ trang web này đến trang web khác. Thuộc tính CSS có thể được sử dụng để tạo kiểu cho các liên kết theo nhiều cách khác nhau.
Trạng thái liên kết. Trước khi thảo luận về các thuộc tính CSS, điều quan trọng là phải biết trạng thái của một liên kết. Các liên kết có thể tồn tại ở các trạng thái khác nhau và chúng có thể được tạo kiểu bằng các lớp giả.
Có bốn trạng thái liên kết được đưa ra bên dưới.
- a. liên kết => Đây là một liên kết bình thường, chưa được truy cập
- a. đã truy cập => Đây là liên kết được người dùng truy cập ít nhất một lần
- a. hover => Đây là link khi rê chuột vào nó
- a. đang hoạt động => Đây là một liên kết vừa được nhấp vào
Cú pháp.
color: black;
text-decoration: none;
1tên_màu có thể được cung cấp ở bất kỳ định dạng nào như tên màu [xanh lục], giá trị HEX [#5570f0] hoặc giá trị RGB rgb[25, 255, 2]. Có một trạng thái khác ‘a. tiêu điểm' được sử dụng để tập trung khi người dùng sử dụng phím tab để điều hướng qua các liên kết.
Giá trị mặc định của liên kết.
- Theo mặc định, các liên kết được tạo được gạch chân
- Khi di chuột lên trên một liên kết, nó sẽ chuyển thành biểu tượng bàn tay
- Các liên kết bình thường/chưa được truy cập có màu xanh lam
- Các liên kết đã truy cập có màu tím
- Liên kết hoạt động được tô màu đỏ
- Khi một liên kết được tập trung, nó có một đường viền xung quanh nó
Ví dụ
html
color: black;
text-decoration: none;
65 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
67 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
21 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______125 color: black;
text-decoration: none;
26 color: black;
text-decoration: none;
25 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______181 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
84 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
86 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
88 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
63____181 color: black;
text-decoration: none;
68_______369____263____121
color: black;
text-decoration: none;
68
color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
32 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
37 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
39 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
651 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
63____332 color: black;
text-decoration: none;
657_______263____367____368
Đầu ra.
Thuộc tính CSS của Liên kết. Một số thuộc tính CSS cơ bản của các liên kết được đưa ra bên dưới.
- màu
- họ phông chữ
- trang trí văn bản
- màu nền
màu. Thuộc tính CSS này được sử dụng để thay đổi màu của văn bản liên kết.
Cú pháp.
color: black;
text-decoration: none;
2Ví dụ.
html
color: black;
text-decoration: none;
65 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
67 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
21 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______125 color: black;
text-decoration: none;
672 color: black;
text-decoration: none;
25 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______181 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
84_______185____3682
_______185____3684
color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23_______183____3689
color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
691 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
693 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
698 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
200 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
202 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
207 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
209 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
211 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83____1216 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
218 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
220 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
63____181 color: black;
text-decoration: none;
68_______369____263____121
color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
32 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______336 color: black;
text-decoration: none;
37 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
242______338 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
245 color: black;
text-decoration: none;
246 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
63____332 color: black;
text-decoration: none;
657_______263____367____368
Đầu ra.
họ phông chữ. Thuộc tính này được sử dụng để thay đổi loại phông chữ của liên kết bằng thuộc tính font-family.
Cú pháp.
color: black;
text-decoration: none;
8Ví dụ.
html
color: black;
text-decoration: none;
65 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
67 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
21 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______181 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
83____1269 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
271 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
273 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
84 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
279_______185____3684
color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
286 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
691 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
290 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83____1295 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
200 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
273 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
804 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
209 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
808 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
813 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
218 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
817 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
63____181 color: black;
text-decoration: none;
68_______369____263____121
color: black;
text-decoration: none;
68
color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
32 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______336 color: black;
text-decoration: none;
37 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
837 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
839____338 color: black;
text-decoration: none;
841 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
843 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
63____332 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
63____367____1852Đầu ra.
Trang trí văn bản. Thuộc tính này về cơ bản được sử dụng để xóa/thêm gạch dưới từ/vào một liên kết.
Cú pháp.
color: black;
text-decoration: none;
6Ví dụ.
html
color: black;
text-decoration: none;
65 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
67 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
21 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______125 color: black;
text-decoration: none;
864 color: black;
text-decoration: none;
25 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______181 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
873 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
84 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
877 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
83____1882 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
884 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
886 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
890 color: black;
text-decoration: none;
83____1892 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
894 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
63____181 color: black;
text-decoration: none;
68_______369____263____121
color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
32 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______336 color: black;
text-decoration: none;
37 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
612 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
841 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
843 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
63____332 color: black;
text-decoration: none;
657_______263____367____368
Đầu ra.
màu nền. Thuộc tính này được sử dụng để thiết lập màu nền của liên kết.
Cú pháp.
color: black;
text-decoration: none;
3Ví dụ.
html
color: black;
text-decoration: none;
65 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
67 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
21 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66____125 color: black;
text-decoration: none;
637 color: black;
text-decoration: none;
25 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______181 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
645 color: black;
text-decoration: none;
83____2647 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
877 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
653 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
691 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
657 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
659 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
661 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
886 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
665 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
670 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
209 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
674 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
676 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
661 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
88 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
886 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
665 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
63____181 color: black;
text-decoration: none;
68_______369____263____121
color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
32 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______336 color: black;
text-decoration: none;
37 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
304 color: black;
text-decoration: none;
245 color: black;
text-decoration: none;
306 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
308 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
63____332 color: black;
text-decoration: none;
657_______263____367____368
Đầu ra.
Nút liên kết CSS. Các liên kết CSS cũng có thể được tạo kiểu bằng các nút/hộp. Ví dụ sau đây cho thấy cách các liên kết CSS có thể được thiết kế dưới dạng các nút.
Ví dụ.
html
color: black;
text-decoration: none;
65 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
67 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
21 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______125 color: black;
text-decoration: none;
329 color: black;
text-decoration: none;
25 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______181 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
645 color: black;
text-decoration: none;
83____2647 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
877 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
271 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
674 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
676 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
661 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
353 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
88 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
886 color: black;
text-decoration: none;
85 color: black;
text-decoration: none;
665 color: black;
text-decoration: none;
83 color: black;
text-decoration: none;
60 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
63____181 color: black;
text-decoration: none;
68_______369____263____121
color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
66 color: black;
text-decoration: none;
32 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
23 color: black;
text-decoration: none;
66______336 color: black;
text-decoration: none;
37 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
304 color: black;
text-decoration: none;
380 color: black;
text-decoration: none;
306 color: black;
text-decoration: none;
38 color: black;
text-decoration: none;
308 color: black;
text-decoration: none;
36 color: black;
text-decoration: none;
68 color: black;
text-decoration: none;
69 color: black;
text-decoration: none;
63____332 color: black;
text-decoration: none;
389_______263____367____368
Đầu ra.
Ghi chú cá nhân của tôi arrow_drop_up
Tiết kiệm