a要素の子要素の有無による適用

ただのテキストリンク
子にspan要素のあるリンク
#box01 a:has(span) {
	text-decoration: none;
}
#box01 a:has(span):hover {
	text-decoration: underline;
}
#box01 a:has(img) {
	width: 150px;
}
#box01 a:has(img):hover {
	opacity: 0.5;
}

要素が3個以上、4個以上の場合適用する

  • リスト1
  • リスト2
  • リスト1
  • リスト2
  • リスト3
  • リスト1
  • リスト2
  • リスト3
  • リスト4
#box03 ul:has(li:nth-last-child(n+3)) li {
	background-color: #138001;
	color: #fff;
}
#box03 ul:has(li:nth-last-child(n+4)) li {
	width: 50%;
}

直後にfigureタグある場合に適用する

普通の見出し

出生地はロンドン。黎明期の電子計算機の一つであるManchester Mark Iの開発チームに参加していた数学者夫妻コンウェイ・バーナーズ=リーとメアリー・リー・ウッズのもとに生まれる。

直後にfigureタグがある見出し

バーナーズ=リーが CERN で使用したNeXTcube。初のWebサーバとなった。

#box04 h4:has(+ figure) {
	color: red;
	text-decoration: underline;
}