{"id":241,"date":"2021-03-21T15:40:09","date_gmt":"2021-03-21T15:40:09","guid":{"rendered":"https:\/\/wshop.fi\/eng\/?p=241"},"modified":"2021-03-21T15:40:10","modified_gmt":"2021-03-21T15:40:10","slug":"css-wildcard-kind-of-css-attribute-selector","status":"publish","type":"post","link":"https:\/\/wshop.fi\/eng\/css-wildcard-kind-of-css-attribute-selector\/","title":{"rendered":"CSS Wildcard (kind of) &#8211; CSS Attribute Selector"},"content":{"rendered":"\n<p><strong>CSS wildcard<\/strong>&nbsp;or&nbsp;<strong>CSS Regular expression?<\/strong>&nbsp;&#8211; You may be looking for CSS Attribute Selector.<\/p>\n\n\n\n<p>CSS Attribute Selector &#8211;&nbsp;Here\u2019s the scenario: You want to add styling to all elements that have \u201cread\u201d in the &nbsp;name of the class.<\/p>\n\n\n\n<p>For instance: Below classes have some of the same wording.<\/p>\n\n\n\n<p>mark-as-unread<br>mark-as-reading<br>mark-as-read<br>mark-as-not-interested<\/p>\n\n\n\n<p>In CSS, selectors are patterns used to select the element(s) you want to style. &nbsp;If you are looking for a&nbsp;<strong>CSS wildcard<\/strong>&nbsp;or&nbsp;<strong>CSS Regular expression<\/strong>&nbsp;then what you might &nbsp;be trying to find is a&nbsp;<strong>CSS Attribute Selector<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CSS Attribute Selector &#8211; HTML &#8211; for\u00a0CSS Wildcard<\/h2>\n\n\n\n<p>*note the space after \u201c-read \u201d for book 3.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"mark-as-unread otherClass\">   Book 1   &lt;\/div>\n&lt;div class=\"mark-as-reading otherClass\">   Book 2   &lt;\/div>\n&lt;div class=\"mark-as-read otherClass\">   Book 3   &lt;\/div>\n&lt;div class=\"mark-as-not-interested otherClass\">   Book 4   &lt;\/div><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">CSS Attribute Selector &#8211; CSS &#8211; for\u00a0CSS Wildcard<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>div&#91;class*='-read'] {color:blue; }\ndiv&#91;class*='-read '] {text-decoration:line-through;}\ndiv&#91;class*='mark-as'] {font-style:italic; }\n.otherClass {font-size:200%;}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">CSS Wildcard or CSS\u00a0Selectors to note<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>^<\/strong>&nbsp;\u2013 matches if the attribute&nbsp;<strong>begins<\/strong>&nbsp;with the given string<\/li><li><strong>$<\/strong>&nbsp;\u2013 matches if the attribute&nbsp;<strong>ends<\/strong>&nbsp;with the given string<\/li><li><strong>*<\/strong>&nbsp;\u2013 matches&nbsp;<strong>any<\/strong>&nbsp;part of the attribute value that&nbsp;<strong>contains<\/strong>&nbsp;given string<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">CSS Selectors List \/ CSS Wildcard Table<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Selector<\/th><th>Example<\/th><th>Example description<\/th><th>CSS<\/th><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attribute.asp\">[<em>attribute<\/em>]<\/a><\/td><td>[target]<\/td><td>Selects all elements with a target attribute<\/td><td>2<\/td><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attribute_value.asp\">[<em>attribute<\/em>=<em>value<\/em>]<\/a><\/td><td>[target=_blank]<\/td><td>Selects all elements with target=\u201d_blank\u201d<\/td><td>2<\/td><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attribute_value_contains.asp\">[<em>attribute<\/em>~=<em>value<\/em>]<\/a><\/td><td>[title~=nickfever]<\/td><td>Selects all elements with a title attribute containing the word \u201cnickfever\u201d<\/td><td>2<\/td><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attribute_value_lang.asp\">[<em>attribute<\/em>|=<em>value<\/em>]<\/a><\/td><td>[lang|=en]<\/td><td>Selects all elements with a lang attribute value starting with \u201cen\u201d<\/td><td>2<\/td><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attr_begin.asp\">[<em>attribute<\/em>^=<em>value<\/em>]<\/a><\/td><td>a[src^=&#8221;https&#8221;]<\/td><td>Selects every &lt;a&gt; element whose src attribute value begins with \u201chttps\u201d<\/td><td>3<\/td><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attr_end.asp\">[<em>attribute<\/em>$=<em>value<\/em>]<\/a><\/td><td>a[src$=&#8221;.pdf&#8221;]<\/td><td>Selects every &lt;a&gt; element whose src attribute value ends with \u201c.pdf\u201d<\/td><td>3<\/td><\/tr><tr><td><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_attr_contain.asp\">[<em>attribute<\/em>*=<em>value<\/em>]<\/a><\/td><td>a[src*=&#8221;nickfever&#8221;]<\/td><td>Selects every &lt;a&gt; element whose src attribute value contains the substring \u201cnickfever\u201d<\/td><td>3<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>CSS wildcard&nbsp;or&nbsp;CSS Regular expression?&nbsp;&#8211; You may be looking for CSS Attribute Selector. CSS Attribute Selector &#8211;&nbsp;Here\u2019s the scenario: You want to add styling to all elements that have \u201cread\u201d in the &nbsp;name of the class. For instance: Below classes have some of the same wording. mark-as-unreadmark-as-readingmark-as-readmark-as-not-interested In CSS, selectors are patterns used to select the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":{"0":"post-241","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-coding"},"_links":{"self":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":1,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts\/241\/revisions\/242"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/media\/119"}],"wp:attachment":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/categories?post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/tags?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}