CSS Attribute Selector

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2022 Jan 22 11:7
Editor
Edited
Edited
2023 Oct 23 5:33
Refs
Refs

style 에 많이 사용

/* <a> elements with an href containing "example" */ a[style*="color: blue"] { font-size: 2em; }
 
/* Internal links, beginning with "#" */ a[href^="#"] { background-color: gold; }
 
/* <a> elements with a title attribute */ a[title] { color: purple; } /* <a> elements with an href matching "https://example.org" */ a[href="https://example.org"] { color: green; } /* <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; }
 
 
 
Attribute selectors - CSS: Cascading Style Sheets | MDN
The CSS attribute selector matches elements based on the presence or value of a given attribute. Represents elements with an attribute name of attr. Represents elements with an attribute name of attr whose value is exactly value. Represents elements with an attribute name of attr whose value is a whitespace-separated list of words, one of which is exactly value.
Attribute selectors - CSS: Cascading Style Sheets | MDN
 
 

Recommendations