{"id":14135,"date":"2012-07-02T23:01:02","date_gmt":"2012-07-02T15:01:02","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=14135"},"modified":"2025-04-04T01:10:22","modified_gmt":"2025-04-03T17:10:22","slug":"css3-attribute-selector","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/","title":{"rendered":"CSS3 Attribute Selector: Targeting the File Type"},"content":{"rendered":"<p><strong>Attribute selectors<\/strong> are incredibly handy for choosing elements without needing extra <code>id<\/code>s or <code>classes<\/code>. If the element you\u2019re targeting has attributes like <code>href<\/code>, <code>src<\/code>, or <code>type<\/code>, there\u2019s no need to add anything else.<\/p>\n<p>These <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.w3.org\/TR\/CSS2\/selector.html\">attribute selectors<\/a> have been a part of CSS since version 2.1. With the introduction of CSS3, more types of attribute selectors have been added, allowing us to specify targets based on the element\u2019s attributes even more accurately.<\/p>\n<p>In this article, we\u2019ll explore how to use a particular syntax to select elements based on the <strong>file type<\/strong> specified in an attribute\u2019s value.<\/p>\n<h2>Syntax and Browser Compatibility<\/h2>\n<p>To target a specific <strong>file type<\/strong>, which is usually found at the end of a file name, we use the syntax <code>[attr$=\"value\"]<\/code>. This employs the <code>$=<\/code> operator to focus on the end of the attribute\u2019s value. For instance:<\/p>\n<pre>\r\na[href$=\".pdf\"]::before {\r\n  background: url('..\/images\/document-pdf-text.png') no-repeat;\r\n}\r\n<\/pre>\n<p>This code snippet targets links ending in <code>.pdf<\/code> and adds a PDF icon in the <code>:before<\/code> pseudo-element.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg\" alt=\"PDF Icon Example\" width=\"500\" height=\"150\"><\/figure>\n<div class=\"sue-icon-text su-image-caption\" data-url=\"\" data-target=\"self\" style=\"min-height:34px;padding-left:36px;color:#333333\">\n<div class=\"sue-icon-text-icon\" style=\"color:#333333;font-size:24px;width:24px;height:24px\"><i class=\"sui sui-photo\" style=\"font-size:24px;color:#333333\"><\/i><\/div>\n<div class=\"sue-icon-text-content su-u-trim\" style=\"color:#333333\"><strong>PDF Icon Source<\/strong>: <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/p.yusukekamiyamane.com\/\">Fugue Icons<\/a><\/div>\n<div style=\"clear:both;height:0\"><\/div>\n<\/div>\n<p>While this approach is a <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.css3.info\/preview\/attribute-selectors\/\">widely used application<\/a> of the selector, <a href=\"https:\/\/www.hongkiat.com\/blog\/coding-graphics-with-css3\/\">the possibilities extend far beyond this example<\/a>.<\/p>\n<p>As for browser support, though this syntax was formally introduced with CSS3, it\u2019s been compatible with browsers as early as <strong>Internet Explorer 7<\/strong>, allowing its use across all modern web designs.<\/p>\n<h2>An Example:<\/h2>\n<p><strong>You\u2019ll never know unless you try<\/strong>. Experimenting with new techniques is key to understanding concepts that might seem complex at first glance. Here, we\u2019ll show how this specific syntax can simplify targeting elements within HTML structures, which might have been challenging to achieve with plain CSS alone.<\/p>\n<p>We will use an <strong><a href=\"https:\/\/www.hongkiat.com\/blog\/building-html5-css-webpages\/\">HTML5 structure<\/a><\/strong> as an example, featuring a list of three images along with their captions. This example is meant to demonstrate the syntax\u2019s application and doesn\u2019t imply that your HTML should match exactly; whether you have fewer or more images, the essence is to grasp how to utilize this syntax effectively within any HTML structure.<\/p>\n<pre>&lt;ul&gt;\r\n&lt;ul&gt;\r\n  &lt;li&gt;\r\n    &lt;figure&gt;\r\n      &lt;img src=\"images\/macpro.jpg\"&gt;\r\n      &lt;figcaption&gt;jpg&lt;\/figcaption&gt;\r\n    &lt;\/figure&gt;\r\n  &lt;\/li&gt;\r\n  &lt;li&gt;\r\n    &lt;figure&gt;\r\n      &lt;img src=\"images\/macpro.png\"&gt;\r\n      &lt;figcaption&gt;png&lt;\/figcaption&gt;\r\n    &lt;\/figure&gt;\r\n  &lt;\/li&gt;\r\n  &lt;li&gt;\r\n    &lt;figure&gt;\r\n      &lt;img src=\"images\/macpro.gif\"&gt;\r\n      &lt;figcaption&gt;gif&lt;\/figcaption&gt;\r\n    &lt;\/figure&gt;\r\n  &lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p>Each image listed comes in one of three formats or extensions: <strong>jpg<\/strong>, <strong>png<\/strong>, and <strong>gif<\/strong>. Additionally, each image has a caption reflecting its extension, which serves as the image\u2019s label.<\/p>\n<p>Our goal is to assign different background colors to the captions based on the image extension: <strong>green<\/strong> for jpg, <strong>blue<\/strong> for png, and <strong>purple<\/strong> for gif.<\/p>\n<p>Let\u2019s begin by setting the figure tag\u2019s position to relative, as we\u2019ll be using <code>absolute<\/code> positioning for the captions.<\/p>\n<pre>\r\nfigure {\r\n  position: relative;\r\n}\r\n<\/pre>\n<p>Next, we\u2019ll add some styling to the images, including borders and shadows, for a bit of visual flair.<\/p>\n<pre>\r\nimg {\r\n  border: 5px solid #ccc;\r\n  -webkit-box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, .5);\r\n  box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, .5); \r\n}\r\n<\/pre>\n<p>Finally, we\u2019ll define the default style and positioning for the captions. Each caption or label will be a 50px square, positioned at the top right of the image.<\/p>\n<pre>\r\nimg + figcaption {\r\n  color: #fff;\r\n  position: absolute;\r\n  top: 0;\r\n  right: 0;\r\n  width: 50px;\r\n  height: 50px;\r\n  line-height: 50px;\r\n  text-align: center;\r\n}\r\n<\/pre>\n<p>Now, let\u2019s introduce the background color. We achieve this by combining the attribute selector with the adjacent sibling selector, <strong>+<\/strong>.<\/p>\n<pre>\r\nimg[src$=\".jpg\"] + figcaption {\r\n  background-color: #a8b700;\r\n}\r\n<\/pre>\n<p>This code targets every image whose source attribute ends with <code>.jpg<\/code>. The adjacent sibling selector then identifies the next element, in this case, applying a background color of <code>#a8b700<\/code> to the <code>figcaption<\/code>.<\/p>\n<p>Below are the codes to apply background colors to captions based on the remaining image formats, .png and .gif.<\/p>\n<pre>\r\nimg[src$=\".png\"] + figcaption {\r\n  background-color: #389abe;\r\n}\r\n\r\nimg[src$=\".gif\"] + figcaption {\r\n  background-color: #8960a7;\r\n}\r\n<\/pre>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-demo-preview.jpg\" alt=\"CSS Attribute Selector Demo Preview\" width=\"500\" height=\"692\"><\/figure>\n<div class=\"sue-icon-text su-image-caption\" data-url=\"\" data-target=\"self\" style=\"min-height:34px;padding-left:36px;color:#333333\">\n<div class=\"sue-icon-text-icon\" style=\"color:#333333;font-size:24px;width:24px;height:24px\"><i class=\"sui sui-photo\" style=\"font-size:24px;color:#333333\"><\/i><\/div>\n<div class=\"sue-icon-text-content su-u-trim\" style=\"color:#333333\">Image sources: <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.flickr.com\/photos\/meewosh\/7226878938\/\" title=\"Mac Pro by Milosz Bolechowski\">MacPro 1<\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.flickr.com\/photos\/kenfagerdotcom\/7362151482\/\" title=\"Mac Pro by Ken Fager\">MacPro 2<\/a>, and MacPro 3<\/div>\n<div style=\"clear:both;height:0\"><\/div>\n<\/div>\n<h2>Wrapping Up<\/h2>\n<p>We hope this demonstration has shown you the possibilities when styling with specialized selectors, like the attribute selector we\u2019ve explored. Next time you\u2019re crafting your HTML, consider investigating if your design goals can be met with such selectors before resorting to adding unnecessary <code>classes<\/code> or <code>id<\/code>s to your well-structured markup.<\/p>\n<p>Interestingly, there are two additional selectors of this nature that we plan to discuss in future posts. So, keep an eye out for those!<\/p>","protected":false},"excerpt":{"rendered":"<p>Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you\u2019re targeting has attributes like href, src, or type, there\u2019s no need to add anything else. These attribute selectors have been a part of CSS since version 2.1. With the introduction of CSS3, more types of attribute selectors&hellip;<\/p>\n","protected":false},"author":113,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3392,352],"tags":[507,4683,506,2016],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>CSS3 Attribute Selector: Targeting the File Type - Hongkiat<\/title>\n<meta name=\"description\" content=\"Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you&#039;re targeting has attributes like\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS3 Attribute Selector: Targeting the File Type\" \/>\n<meta property=\"og:description\" content=\"Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you&#039;re targeting has attributes like\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-02T15:01:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-03T17:10:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg\" \/>\n<meta name=\"author\" content=\"Thoriq Firdaus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@tfirdaus\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thoriq Firdaus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/\"},\"author\":{\"name\":\"Thoriq Firdaus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\"},\"headline\":\"CSS3 Attribute Selector: Targeting the File Type\",\"datePublished\":\"2012-07-02T15:01:02+00:00\",\"dateModified\":\"2025-04-03T17:10:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/\"},\"wordCount\":623,\"commentCount\":25,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-source-selector\\\/css3-attr-selector-example.jpg\",\"keywords\":[\"CSS\",\"CSS Selectors\",\"HTML\",\"HTML5 \\\/ CSS3 Tutorials\"],\"articleSection\":[\"Coding\",\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/\",\"name\":\"CSS3 Attribute Selector: Targeting the File Type - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-source-selector\\\/css3-attr-selector-example.jpg\",\"datePublished\":\"2012-07-02T15:01:02+00:00\",\"dateModified\":\"2025-04-03T17:10:22+00:00\",\"description\":\"Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you're targeting has attributes like\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-source-selector\\\/css3-attr-selector-example.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-source-selector\\\/css3-attr-selector-example.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-attribute-selector\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS3 Attribute Selector: Targeting the File Type\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\",\"name\":\"Thoriq Firdaus\",\"description\":\"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.\",\"sameAs\":[\"https:\\\/\\\/thoriq.com\",\"https:\\\/\\\/x.com\\\/tfirdaus\"],\"jobTitle\":\"Web Developer\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/thoriq\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"CSS3 Attribute Selector: Targeting the File Type - Hongkiat","description":"Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you're targeting has attributes like","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/","og_locale":"en_US","og_type":"article","og_title":"CSS3 Attribute Selector: Targeting the File Type","og_description":"Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you're targeting has attributes like","og_url":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2012-07-02T15:01:02+00:00","article_modified_time":"2025-04-03T17:10:22+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg","type":"","width":"","height":""}],"author":"Thoriq Firdaus","twitter_card":"summary_large_image","twitter_creator":"@tfirdaus","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Thoriq Firdaus","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/"},"author":{"name":"Thoriq Firdaus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807"},"headline":"CSS3 Attribute Selector: Targeting the File Type","datePublished":"2012-07-02T15:01:02+00:00","dateModified":"2025-04-03T17:10:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/"},"wordCount":623,"commentCount":25,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg","keywords":["CSS","CSS Selectors","HTML","HTML5 \/ CSS3 Tutorials"],"articleSection":["Coding","Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/","url":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/","name":"CSS3 Attribute Selector: Targeting the File Type - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg","datePublished":"2012-07-02T15:01:02+00:00","dateModified":"2025-04-03T17:10:22+00:00","description":"Attribute selectors are incredibly handy for choosing elements without needing extra ids or classes. If the element you're targeting has attributes like","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-source-selector\/css3-attr-selector-example.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/css3-attribute-selector\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"CSS3 Attribute Selector: Targeting the File Type"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807","name":"Thoriq Firdaus","description":"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.","sameAs":["https:\/\/thoriq.com","https:\/\/x.com\/tfirdaus"],"jobTitle":"Web Developer","url":"https:\/\/www.hongkiat.com\/blog\/author\/thoriq\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-3FZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/14135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=14135"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/14135\/revisions"}],"predecessor-version":[{"id":73530,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/14135\/revisions\/73530"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=14135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=14135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=14135"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=14135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}