{"id":56,"date":"2024-08-27T12:14:35","date_gmt":"2024-08-27T09:14:35","guid":{"rendered":"https:\/\/planeta21vek.ru\/elina732\/eng\/?p=56"},"modified":"2025-11-20T20:53:39","modified_gmt":"2025-11-20T17:53:39","slug":"atribut-class","status":"publish","type":"post","link":"https:\/\/planeta21vek.ru\/elina732\/eng\/2024\/08\/27\/atribut-class\/","title":{"rendered":"Global class attribute"},"content":{"rendered":"<p style=\"text-align: justify;\">The global class attribute is a space-separated list of case-dependent classes of an element. Classes allow CSS and Javascript to select and access them using class selectors or functions such as the DOM document.getElementsByClassName methods. Developers use the class attribute all the time. Not only does it make styling easier, but it also helps keep your code organized and maintainable.<\/p>\n<p><!--more--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-57\" src=\"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-content\/uploads\/2024\/08\/class270824.png\" alt=\"\" width=\"667\" height=\"306\" srcset=\"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-content\/uploads\/2024\/08\/class270824.png 667w, https:\/\/planeta21vek.ru\/elina732\/eng\/wp-content\/uploads\/2024\/08\/class270824-300x138.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><br \/>\n\n<p><span style=\"color: #993300;\"><strong>Example 1<\/strong><\/span><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;p class=&quot;note editorial&quot;&gt;Above point sounds a bit obvious. Remove\/rewrite?&lt;\/p&gt;\r\n&lt;p&gt;Narrator: I must warn you now folks that this beginning is very exciting.&lt;\/p&gt;\r\n&lt;p class=&quot;note&quot;&gt;&#x5B;Lights go up and wind blows; Caspian enters stage right]&lt;\/p&gt;\r\n<\/pre>\n<p>One element can be assigned one or more classes, separated by spaces.<\/p>\n<p><span style=\"color: #993300;\"><strong>Example 2<\/strong><\/span><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!-- One class --&gt;\r\n&lt;div class=&quot;container&quot;&gt;\r\n&lt;!-- ... --&gt;\r\n&lt;\/div&gt;\r\n&lt;!-- Multiple classes --&gt;\r\n&lt;div class=&quot;container special-box&quot;&gt;\r\n&lt;!-- ... --&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p><span style=\"color: #993300;\"><strong>Example 3<\/strong><\/span><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n.highlighted-text {\r\nbackground-color: yellow;\r\nfont-size: 18px;\r\n}\r\n&lt;span class=&quot;highlighted-text&quot;&gt;This text will be highlighted.&lt;\/span&gt;\r\n\r\n<\/pre>\n<p><span style=\"color: #993300;\"><strong>Example 4<\/strong><\/span><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nconst elements = document.querySelectorAll(&amp;#039;.clickable&amp;#039;);\r\nelements.forEach(element =&gt; {\r\nelement.addEventListener(&amp;#039;click&amp;#039;, () =&gt; {\r\nalert(&amp;#039;\u041a\u043b\u0438\u043a!&amp;#039;);\r\n});\r\n});\r\n\r\n&lt;button class=&quot;click&quot;&gt;Next&lt;\/button&gt;\r\n<\/pre>\n<p>Complex Selectors in CSS: In some cases, we need to apply a class only to a specific HTML tag, ignoring all others.<\/p>\n<p><span style=\"color: #993300;\"><strong>Example 5<\/strong><\/span><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\/* Only for &lt;p&gt; elements with class special-text *\/\r\np.special-text {\r\ncolor: blue;\r\n}\r\n\r\n&lt;p class=&quot;special-text&quot;&gt;This text will be blue.&lt;\/p&gt;\r\n&lt;div class=&quot;special-text&quot;&gt;And this one will remain unchanged.&lt;\/div&gt;\r\n<\/pre>\n\n","protected":false},"excerpt":{"rendered":"<p>The global class attribute is a space-separated list of case-dependent classes of an element. Classes allow CSS and Javascript to select and access them using class selectors or functions such as the DOM document.getElementsByClassName methods. Developers use the class attribute all the time. Not only does it make styling easier, but it also helps keep your code organized and maintainable.<\/p>\n","protected":false},"author":1,"featured_media":57,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,7],"tags":[15,16,13,43],"class_list":{"0":"post-56","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-htmlverstka","8":"category-programmirovanie","9":"tag-class","10":"tag-css","11":"tag-html","12":"tag-selectors"},"_links":{"self":[{"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":6,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/posts\/56\/revisions\/310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/media\/57"}],"wp:attachment":[{"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planeta21vek.ru\/elina732\/eng\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}