Skip to main content

Thẻ HTML link rel=alternate

Trong HTML, thẻ <link> thường dùng để liên kết các file file CSS hay favicon:

<link rel="stylesheet" type="text/css" href="./theme/css/custom.css" media="screen">
<link rel="icon" href="favicon.ico" />

The <link> HTML element specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link

Ngoài hai giá trị rel (relation) stylesheet, icon nói trên, còn nhiều giá trị khác, trong đó đáng chú ý là alternate

The rel attribute defines the relationship between a linked resource and the current document

Alternate representations of the current document.

rel="alternate" dùng để liên kết tới các phiên bản, định dạng thay thế của trang web hiện tại:

  • trang dành riêng cho ngôn ngữ khác
  • biểu diễn khác thay vì HTML: RSS/XML - RSS feed

Ví dụ trên https://wordpress.com:

<link rel="alternate" hreflang="ja" href="https://wordpress.com/ja/" />
<link rel="alternate" hreflang="vi" href="https://wordpress.com/vi/" />
<link rel="alternate" type="application/rss+xml" title="WordPress.com Blog" href="https://wordpress.com/blog/feed/" />
<link rel="alternate" type="application/rss+xml" title="WordPress.com Discover" href="//discover.wordpress.com/feed/" />

Các chương trình đọc RSS (RSS reader) có thể tự tìm trong mã nguồn HTML của trang (page source) các thẻ <link rel="alternate" type="application/rss+xml"> để tìm ra đường dẫn tới feed, ngay cả khi chúng không hiện trực tiếp lên trang chủ.

Kết luận

<link rel="alternate"> là nơi chứa thông tin quan trọng, dù không hiện trực tiếp lên giao diện người dùng.

Hết.

HVN at https://pymi.vn and https://www.familug.org.

Ủng hộ tác giả 🍺

Comments

Popular posts from this blog

Tài liệu và hướng dẫn học Python

Để tiết kiệm thời gian, tốt nhất là đi học PyMI Updated: 130617 Sau đây là các tài liệu khuyên dùng: Vì nhiều lý do, nên học python2.7 tại thời điểm hiện tại (giờ là tháng 6/2013 - muốn biết tại sao thì tự tìm hiểu) python 3.5+ (giờ là tháng 2/2017) Chuẩn bị: 1. biết bật tắt máy 2. biết cài python 3. tập gõ 10 ngón - gõ 2 ngón hay 1 ngón cũng không sao, nhưng 10 ngón là cách dễ nhất để gõ nhanh nhất. Tài liệu - Nên dùng tài liệu tại trang chủ của Python làm chính, tham khảo thêm các tài liệu khác tại http://www.familug.org/2016/12/free-ebook.html Căn bản, mới học 1.1 Python PyMI.vn https://pymi.vn/tutorial/ 1.2. Python offical tutorial kết hợp làm bài tập trên HackerRank  (đề bài bằng tiếng Anh, nhưng Google translate 1 lúc cũng ra vì có nhiều ví dụ mẫu đi kèm). Học viên của Pymi.vn có rất nhiều học viên đã tự học với Learn Python the hard way nhưng chưa thấy ai thành công cả. Hai link dưới nên đọc sau khi đã nắm được những phần cơ bản của ngôn ngữ pytho...

The PyMiers

New FAMILUG