{"id":55831,"date":"2022-05-18T03:01:00","date_gmt":"2022-05-17T17:01:00","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=55831"},"modified":"2022-05-18T11:01:08","modified_gmt":"2022-05-18T01:01:08","slug":"html-attribute-css-pseudo-class-styling-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-attribute-css-pseudo-class-styling-tutorial\/","title":{"rendered":"HTML Attribute CSS Pseudo Class Styling Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.htm\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Attribute CSS Pseudo Class Styling Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.jpg\" title=\"HTML Attribute CSS Pseudo Class Styling Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">HTML Attribute CSS Pseudo Class Styling Tutorial<\/p><\/div>\n<p>Around here with the wording of our blog posts we try to get it right when differentiating an HTML &#8220;attribute&#8221; as distinct from a CSS &#8220;property&#8221;.  Over time, the best explanation we can give for HTML attribute is that it is the <font color=blue>word before<\/font> &#8220;=&#8221; with the outerHTML view of an HTML element &#8230;<\/p>\n<p><code><br \/>\n&lt;select <font color=blue>style<\/font>='width:420px;' <font color=blue>onchange<\/font>=\"jsway(this);\" <font color=blue>size<\/font>=8&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Canberra' <font color=blue>data-area<\/font>='2,358' <font color=blue>data-population<\/font>='430,469' <font color=blue>data-value<\/font>='8' <font color=blue>value<\/font>='7'&gt;Australian Capital Territory&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Sydney' <font color=blue>data-area<\/font>='809,952' <font color=blue>data-population<\/font>='8,186,789' <font color=blue>data-value<\/font>='5' <font color=blue>value<\/font>='1'&gt;New South Wales&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Darwin' <font color=blue>data-area<\/font>='1,419,630' <font color=blue>data-population<\/font>='245,865' <font color=blue>data-value<\/font>='3' <font color=blue>value<\/font>='8'&gt;Northern Territory&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Brisbane' <font color=blue>data-area<\/font>='1,851,736' <font color=blue>data-population<\/font>='5,240,520' <font color=blue>data-value<\/font>='2' <font color=blue>value<\/font>='3'&gt;Queensland&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Adelaide' <font color=blue>data-area<\/font>='1,044,353' <font color=blue>data-population<\/font>='1,772,787' <font color=blue>data-value<\/font>='4' <font color=blue>value<\/font>='5'&gt;South Australia&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Hobart' <font color=blue>data-area<\/font>='90,758' <font color=blue>data-population<\/font>='540,839' <font color=blue>data-value<\/font>='7' <font color=blue>value<\/font>='6'&gt;Tasmania&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Melbourne' <font color=blue>data-area<\/font>='237,657' <font color=blue>data-population<\/font>='6,643,062' <font color=blue>data-value<\/font>='6' <font color=blue>value<\/font>='2'&gt;Victoria&lt;\/option&gt;<br \/>\n&lt;option <font color=blue>data-capital<\/font>='Perth' <font color=blue>data-area<\/font>='2,642,753' <font color=blue>data-population<\/font>='2,685,165' <font color=blue>data-value<\/font>='1' <font color=blue>value<\/font>='4'&gt;Western Australia&lt;\/option&gt;<br \/>\n&lt;\/select&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; with those &#8220;data-&#8221; prefixed ones sometimes referred to as <a target=_blank title='Global data attributes information from W3schools' href='https:\/\/www.w3schools.com\/tags\/att_global_data.asp'>global data attributes<\/a>, and in the early days we were tempted to describe this as a &#8220;property&#8221;, but no, &#8220;property&#8221; is more a CSS th<strike>a<\/strike>ing, as per them being the <font color=purple>word before<\/font> &#8220;:&#8221; &#8230;<\/p>\n<p><code><br \/>\n&lt;style&gt;<br \/>\noption<font color=red>:hover::before<\/font> {<br \/>\n    <font color=purple>content<\/font>: ' (Population Order ' attr(<font color=olive>value<\/font>) ': ' attr(<font color=olive>data-population<\/font>) ') ';  <font color=purple>font-size<\/font>: .7em;<br \/>\n}<br \/>\noption<font color=red>:active::after<\/font> {<br \/>\n    <font color=purple>content<\/font>: ' (Area Order ' attr(<font color=olive>data-value<\/font>) ': ' attr(<font color=olive>data-area<\/font>) ' km\\0000B2 ) ';  <font color=purple>font-size<\/font>: .7em;<br \/>\n}<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; while CSS <a target=_blank title='CSS Pseudo-class information from W3schools' href='https:\/\/www.w3schools.com\/css\/css_pseudo_classes.asp'>Pseudo-classes<\/a> <font color=red>highlighted in red above also exist after &#8220;:&#8221; but in the selector CSS parts<\/font> &#8230;<\/p>\n<blockquote cite='https:\/\/www.w3schools.com\/css\/css_pseudo_classes.asp'><p>\nA pseudo-class is used to define a special state of an element.<br \/>\n<br \/>\nFor example, it can be used to:<br \/>\n<br \/>\nStyle an element when a user mouses over it<br \/>\nStyle visited and unvisited links differently<br \/>\nStyle an element when it gets focus\n<\/p><\/blockquote>\n<p>Can these woooooooorrrrrrlllllldddds meet?  We think so, and thanks to <a target=_blank title='&lt;data&gt;: The Data element - HTML: HyperText Markup Language | MDN' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/data'>&lt;data&gt;: The Data element &#8211; HTML: HyperText Markup Language | MDN<\/a> for help here.  Within the &#8220;value&#8221; part of a CSS &#8220;property&#8221; you can define, via the CSS <a target=_blank title='attr() - CSS: Cascading Style Sheets | MDN' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/attr'>attr()<\/a> function &#8230;<\/p>\n<blockquote cite='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/attr'><p>\nThe attr() CSS function is used to retrieve the value of an attribute of the selected element and use it in the stylesheet. It can also be used on pseudo-elements, in which case the value of the attribute on the pseudo-element&#8217;s originating element is returned.\n<\/p><\/blockquote>\n<p> &#8230; where what you put within the rounded brackets of your attr() definition can correspond to an <font color=olive>HTML element &#8220;attribute&#8221;<\/font> and, thereby, the &#8220;value&#8221; of that HTML &#8220;attribute&#8221; gets <i>plonked<\/i> there, usefully, in an XML feeling way that elements can contain &#8220;attribute&#8221; data of use.<\/p>\n<p>Well, by now, we&#8217;ve written out a lot of our &#8220;proof of concept&#8221; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.html_GETME\">css_attr_value.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.html\" title='Click picture'>web application<\/a> that you can try below &#8230;<\/p>\n<p><iframe style='width:100%;height:340px;' src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.html\"><\/iframe><\/p>\n<p> &#8230; or for a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.html-GETME\">mobile friendly adjusted scenario<\/a>, try <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.html-GETME\">css_attr_value.htm<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.htm\" title='Click picture'>web application<\/a> that you can try below &#8230;<\/p>\n<p><iframe style='width:100%;height:390px;' src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_attr_value.htm\"><\/iframe><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d55831' onclick='var dv=document.getElementById(\"d55831\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/attribute\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d55831' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Around here with the wording of our blog posts we try to get it right when differentiating an HTML &#8220;attribute&#8221; as distinct from a CSS &#8220;property&#8221;. Over time, the best explanation we can give for HTML attribute is that it &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-attribute-css-pseudo-class-styling-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[112,281,290,3980,471,3981,576,1861,997,2232,1976,1953,1209,1319,1480],"class_list":["post-55831","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-attribute","tag-css","tag-data","tag-data-attribute","tag-function","tag-global-data-attribute","tag-html","tag-outerhtml","tag-programming","tag-property","tag-pseudo-class","tag-selector","tag-style","tag-tutorial","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55831"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=55831"}],"version-history":[{"count":16,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55831\/revisions"}],"predecessor-version":[{"id":55847,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55831\/revisions\/55847"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=55831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=55831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=55831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}