본문 바로가기

programming/Web

CSS3 특성 선택자(Selector)

특성 선택자란? 

주어진 특성의 존재 여부나 그 값에 따라 요소를 선택하는 것

<!-- html -->

<ul>
    <li><a title="hello" href="#">title link</a></li>
    <li><a className="hellologo" href="#internal">Internal link</a></li>
    <li><a href="https://example.com">https://example.com</a></li>
    <li><a href="#InSensitive">Insensitive internal link</a></li>
    <li><a href="http://example.org">http://example.org</a></li>
</ul>
/* css */

/* <a> elements with a title attribute */
a[title] {
  color: red;
}

/* <a> elements with an href matching "https://example.org" */
a[href="https://example.com"] {
  color: green;
}

/* <a> elements with an href containing "example" */
a[href*="example"] {
  font-size: 2em;
}

/* <a> elements with an href ending ".org" */
a[href$=".org"] {
  font-style: italic;
}

/* <a> elements whose class attribute contains the word "logo" */
a[class~="logo"] {
  padding: 2px;
}

 

[실행결과]

'programming > Web' 카테고리의 다른 글

[AWS] IAM 이란? (개념과 실습)  (0) 2022.04.05
API, SDK, Library, Framework  (0) 2022.03.10
REST Service에 대하여  (0) 2022.03.05
HTTP 헤더 총정리  (0) 2022.03.04
브라우저 저장소 비교 (localStorage, SessionStorage, Cookie)  (0) 2022.02.17