ホームページ >ウェブフロントエンド >CSSチュートリアル >rel(html属性)
<code class="language-html"><!DOCTYPE html> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Understanding the HTML rel Attribute</title> <h1>The `rel` Attribute: Defining Relationships in HTML</h1> <p>The <code>rel</code> attribute specifies the relationship between the current document and the linked resource. It's primarily used with the <code><link></code> and <code><a></code> tags to provide context and meaning to links.</p> <h2>Common Uses of the `rel` Attribute</h2> <h3>Stylesheets</h3> <p>The most common use is linking stylesheets: <code><link rel="stylesheet" href="styles.css"></code>. This clearly indicates the linked file is a stylesheet.</p> <h3>Alternate Stylesheets</h3> <p>You can define multiple stylesheets using <code>rel="alternate stylesheet"</code>. However, browser support for easily switching between these is limited. A JavaScript-based solution is often necessary for user selection.</p> <pre class="brush:php;toolbar:false"><code> <link href="main.css" media="screen" rel="stylesheet" type="text/css"> <link rel="alternate stylesheet" title="Higher Contrast" href="contrast.css" type="text/css" media="screen"> <link rel="alternate stylesheet" title="Gratuitous CSS" href="hot.css" type="text/css" media="screen"> </code>
title
属性の使用に注意してください。このテキストは、ブラウザのスタイルシート選択メニュー(利用可能な場合)に表示されます。
rel="alternate"
favicons
<code> <link rel="alternate" type="application/rss+xml" href="/rss.xml" title="RSS 2.0"> <link rel="alternate" type="application/atom+xml" href="/atom.xml" title="Atom 1.0"> </code>favicon(Webサイトアイコン)を指定するには、
rel="shortcut icon"
ページ関係(ナビゲーション)
<code> <link href="/favicon.ico" rel="shortcut icon"> </code>および
rel="next"
rel="prev"
を使用してページコンテンツのライセンスを示すことができ、ライセンスの詳細へのリンクを提供できます。
よくある質問rel="license"
はい、rel
や
rel="stylesheet"
rel="nofollow"
と同様に、ハイパーリンクにセマンティックな意味を追加します(例えば、rel="canonical"
)。
)。rel="alternate"
rel = "icon"属性は何をしますか?<link>
rel="nofollow"
WebサイトにFaviconを指定します
rel = "next"とrel = "prev"?rel="nofollow noopener"
の違いは何ですか?
以上がrel(html属性)の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。