CSSを使用したリンクのスタイリング
CSSを使用してリンクのスタイルを設定するには、最初に次のリンク状態を知っておく必要があります:リンク、訪問済み、ホバー、アクティブ。リンクのスタイルを設定するには、アンカー要素の疑似クラスを使用します-
a:link for link a:visited forvisited link a:link for hover on link a:active for active link
例
例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
color: orange;
text-decoration: underline;
}
a:hover {
color: red;
text-decoration: underline;
}
a:active {
color: green;
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Tutorials</h1>
<p><a href="https://www.tutorialspoint.com/java">Java</a></p>
<p><a href="https://www.tutorialspoint.com/chsharp">C#</a></p>
<p><a href="https://www.tutorialspoint.com/jquery">jQuery</a></p>
<p><a href="https://www.tutorialspoint.com/ruby">Ruby</a></p>
<p><a href="https://www.tutorialspoint.com/pytorch">PyTorch</a></p>
</body>
</html> 出力
例
別の例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
color: blue;
text-decoration: none;
}
a:hover {
color: blue;
text-decoration: none;
}
a:active {
color: blue;
text-decoration: none;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<div>
<p>This is the <a href="https://tutorialspoint.com">reference</a></p>
</div>
</body>
</html> 出力
-
CSS属性セレクターを使用したフォームのスタイリング
CSSの属性セレクターを使用して、特定の属性を持つHTML要素にスタイルを適用します。属性セレクターには次のルールが適用されます。 p [lang] −lang属性を持つすべての段落要素を選択します。 p [lang =fr] −lang属性の値が正確に「fr」であるすべての段落要素を選択します。 p [lang〜=fr] −lang属性に「fr」という単語が含まれているすべての段落要素を選択します。 p [lang | =en] − lang属性に正確に「en」であるか、「en-」で始まる値が含まれているすべての段落要素を選択します。 以下は、C
-
CSSを使用したFirst-Lettersのスタイリング::first-letter
CSSは、::first-letter疑似要素を使用して要素の最初の文字のスタイルを設定するのに役立ちます。句読点、有向グラフ、およびコンテンツプロパティによって、最初の文字が変更される可能性があることに注意してください。 次の例は、CSS::first-letter疑似要素を示しています。 例 <!DOCTYPE html> <html> <head> <style> body { text-align: center; } ::first-letter { font-size: 3em;