{"id":7323,"date":"2020-06-08T22:27:40","date_gmt":"2020-06-08T20:27:40","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=7323"},"modified":"2020-06-08T11:44:19","modified_gmt":"2020-06-08T09:44:19","slug":"css-pseudo-selectors-you-might-have-missed-bits-and-pieces","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2020\/06\/08\/css-pseudo-selectors-you-might-have-missed-bits-and-pieces\/","title":{"rendered":"CSS Pseudo-Selectors You Might Have Missed &#8211; Bits and Pieces"},"content":{"rendered":"<blockquote><p>Useful CSS pseudo-classes that are often overlooked.<\/p><\/blockquote>\n<p>Source: <em><a href=\"https:\/\/blog.bitsrc.io\/css-pseudo-selectors-you-never-knew-existed-b5c0ddaa8116\">CSS Pseudo-Selectors You Might Have Missed &#8211; Bits and Pieces<\/a><\/em><\/p>\n<p><!--nextpage--><\/p>\n<blockquote>\n<blockquote class=\"ie\">\n<p id=\"d124\" class=\"ip ig aw as ds b iq ij ik il im in io\" data-selectable-paragraph=\"\"><em class=\"ir\">(Pseudo) selectors let you assign styles to what are, in effect, phantom classes that are inferred by the state of certain elements, or markup patterns within the document, or even by the state of the document itself.<\/em><\/p>\n<p id=\"40e1\" class=\"ip ig aw as ds b iq is it iu iv iw io\" data-selectable-paragraph=\"\"><em class=\"ir\">\u2014 CSS: The Definitive Guide: Eric Meyer, Estelle Weyl<\/em><\/p>\n<\/blockquote>\n<p id=\"6755\" class=\"ix ji dr as iz b ek ja jj em jb jk jc jd ex je jf ey jg jh ez io dj\" data-selectable-paragraph=\"\">This post is a sort-of encouragement to use more plain CSS and less JS when building your UI. Getting familiar with everything CSS has to offer is one way to achieving that \u2014 another one is implementing best practices and reusing that code, as much as possible.<\/p>\n<p id=\"bedc\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">Pseudo-Selectors are in categories: Pseudo-Classes and Pseudo-Elements.<\/p>\n<p id=\"fe7b\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">Pseudo-Class acts as if a class has been attached to an element and styles the element on that basis, whereas a Pseudo-Element acts as if an element has been injected into another element and just the injected element is styled.<\/p>\n<p id=\"3f63\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">Pseudo-Classes has double colons :: while Pseudo-Elements has a single colon :.<\/p>\n<p id=\"a2dc\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">To reuse your UI components try using cloud component hubs like <a class=\"cp gk jq jr js jt\" href=\"https:\/\/bit.dev\" target=\"_blank\" rel=\"noopener noreferrer\"><strong class=\"iz ju\">Bit.dev<\/strong><\/a>. Use it to publish, document and organize all your team\u2019s reusable UI components. It\u2019s not only a way to build faster but also a way to build better as it encourages you to standardize and modularize your code.<\/p>\n<figure class=\"hg hh hi hj hk gw db dc paragraph-image\">\n<div class=\"db dc jv\">\n<div class=\"hw r hp hx\">\n<div class=\"jw hz r\">\n<div class=\"qx xv s t u ht ai br hu hv\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"s t u ht ai ia ib ic\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2020\/06\/1Nj2EzGOskF51B5AKuR-szw.jpg?resize=800%2C421&#038;ssl=1\" width=\"800\" height=\"421\"\/><\/div>\n<p><img class=\"hr hs s t u ht ai id\" role=\"presentation\" sizes=\"700px\" srcset=\"https:\/\/miro.medium.com\/max\/552\/1*Nj2EzGOskF51B5AKuR-szw.gif 276w, https:\/\/miro.medium.com\/max\/1104\/1*Nj2EzGOskF51B5AKuR-szw.gif 552w, https:\/\/miro.medium.com\/max\/1280\/1*Nj2EzGOskF51B5AKuR-szw.gif 640w, https:\/\/miro.medium.com\/max\/1400\/1*Nj2EzGOskF51B5AKuR-szw.gif 700w\" width=\"800\" height=\"421\"\/><\/p>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"jx jy dd db dc jz ka ar cl cm at aw\" data-selectable-paragraph=\"\">Exploring shared UI components on <a class=\"cp gk jq jr js jt\" href=\"https:\/\/bit.dev\" target=\"_blank\" rel=\"noopener noreferrer\">bit.dev<\/a><\/figcaption><\/figure>\n<h1 id=\"17c1\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\">::first-line | Selects the first line of text<\/h1>\n<p id=\"8754\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This pseudo selector affects the first line of text before a line breaks. It styles just the first line of text inside it, as if an element was wrapped around just that text.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"385c\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">p:first-line {\n    color: lightcoral;\n}<\/span><\/pre>\n<h1 id=\"4140\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\">::first-letter | Selects the first letter<\/h1>\n<p id=\"f86c\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This pseudo selector applies to the first letter of the text in an element.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"96db\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv p:first-letter {\n    color: lightcoral;\n    font-size: 40px\n}<\/span><\/pre>\n<h1 id=\"e32c\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">::selection | Selects t<\/code>he highlighted (selected) area<\/h1>\n<p id=\"a4e7\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This applies to any area that has been highlighted by the user.<\/p>\n<p id=\"d763\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">With the <code class=\"\" data-line=\"\">::selection<\/code> pseudo-selector, we can apply our styling to the area that we highlight.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"79cf\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">div::selection {\n    background: yellow;\n}<\/span><\/pre>\n<h1 id=\"6b09\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:root | <\/code>Basic element<\/h1>\n<p id=\"20c0\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">The <code class=\"\" data-line=\"\">:root<\/code> pseudo-class selects the root element of the document. In HTML, it is always the HTML element. In RSS, it is the RSS element.<\/p>\n<p id=\"3ce4\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This pseudo selector is most used to store global rule values using CSS variable as it applies to the root element.<\/p>\n<h1 id=\"1de6\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:empty | <\/code>Applies only if the item is empty<\/h1>\n<p id=\"66f0\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This pseudo selector will select any element that has no children of any kind. The element must be empty. An element is empty if it has no whitespace, visible content, or descendant elements.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"05a1\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">div:empty {\n    border: 2px solid orange;\n}<\/span><span id=\"c5a4\" class=\"ku kc dr as kv b fl lc ld le lf lg kx r ky\" data-selectable-paragraph=\"\">&lt;div&gt;&lt;\/div&gt;\n&lt;div&gt;&lt;\/div&gt;\n&lt;div&gt;\n&lt;\/div&gt;<\/span><\/pre>\n<p id=\"71b8\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">The rule will apply to empty div elements. The rule will be applied to the first and second div because they are truly empty, not the third div because it has whitespace.<\/p>\n<h1 id=\"e9e5\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:only-child | <\/code>Selects an only child<\/h1>\n<p id=\"67dd\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This applies to an element that is the only child of its parent element.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"5fe3\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv p:only-child {\n    color: orangered;\n}<\/span><\/pre>\n<h1 id=\"d268\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:first-of-type | Selects the <\/code>first child element of a specified type<\/h1>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"42e9\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">p:first-of-type {\n    color: orangered;\n}<\/span><\/pre>\n<p id=\"22ba\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This will select any paragraph which is the first paragraph inside another element, as if a class had been added to the paragraph itself.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"130a\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv p:first-of-type {\n    color: orangered;\n}<\/span><\/pre>\n<p id=\"335a\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This would apply to the first child of <code class=\"\" data-line=\"\">.innerDiv<\/code> of <code class=\"\" data-line=\"\">p<\/code> paragraph element.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"d1cb\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">&lt;div class=\"innerDiv\"&gt;\n    &lt;div&gt;Div1&lt;\/div&gt;\n    &lt;p&gt;These are the necessary steps&lt;\/p&gt;\n    &lt;p&gt;hiya&lt;\/p&gt;\n    \n    &lt;p&gt;\n        Do &lt;em&gt;not&lt;\/em&gt; push the brake at the same time as the accelerator.\n    &lt;\/p&gt;\n    &lt;div&gt;Div2&lt;\/div&gt;\n&lt;\/div&gt;<\/span><\/pre>\n<p id=\"1380\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">The p <code class=\"\" data-line=\"\">(&quot;These are the necessary step&quot;)<\/code> would be selected.<\/p>\n<h1 id=\"1e79\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:last-of-type | Selects the l<\/code>ast child element of a specified type<\/h1>\n<p id=\"8a6b\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">Same as <code class=\"\" data-line=\"\">:first-of-type<\/code>, but this will affect the last child element of the same type.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"1498\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv p:last-of-type {\n    color: orangered;\n}<\/span><\/pre>\n<p id=\"c638\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This would apply to the last child of <code class=\"\" data-line=\"\">innerDiv<\/code> of type <code class=\"\" data-line=\"\">p<\/code> paragraph element.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"3360\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">&lt;div class=\"innerDiv\"&gt;\n    &lt;p&gt;These are the necessary steps&lt;\/p&gt;\n    &lt;p&gt;hiya&lt;\/p&gt;\n    &lt;div&gt;Div1&lt;\/div&gt;\n    &lt;p&gt;\n        Do the same.\n    &lt;\/p&gt;\n    &lt;div&gt;Div2&lt;\/div&gt;\n&lt;\/div&gt;<\/span><\/pre>\n<p id=\"dd6e\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">So, the <code class=\"\" data-line=\"\">p<\/code> element <code class=\"\" data-line=\"\">(&quot;Do the same&quot;)<\/code> would be selected.<\/p>\n<h1 id=\"dc59\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:nth-of-type() | <\/code>Selects the child element of a specified type<\/h1>\n<p id=\"5398\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This selector would select an element of a certain type from the list of the specified parent element.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"b346\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv p:nth-of-type(1) {\n    color: orangered;\n}<\/span><\/pre>\n<h1 id=\"04cc\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:nth-last-of-type() | <\/code>Selects the child element of a type by the end of a list<\/h1>\n<p id=\"cfe2\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This will select the last child element of a certain type.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"58a0\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv p:nth-last-of-type() {\n    color: orangered;\n}<\/span><\/pre>\n<p id=\"9efe\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This will select the last child element in the list contained in the <code class=\"\" data-line=\"\">innerDiv<\/code> element and of type, paragraph element.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"43d5\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">&lt;div class=\"innerDiv\"&gt;\n    &lt;p&gt;These are the necessary steps&lt;\/p&gt;\n    &lt;p&gt;hiya&lt;\/p&gt;\n    &lt;div&gt;Div1&lt;\/div&gt;\n    &lt;p&gt;\n        Do the same.\n    &lt;\/p&gt;\n    &lt;div&gt;Div2&lt;\/div&gt;\n&lt;\/div&gt;<\/span><\/pre>\n<p id=\"84f9\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">The p <code class=\"\" data-line=\"\">Do the same<\/code> is the last paragraph child element inside the <code class=\"\" data-line=\"\">innerDiv<\/code> so it will be selected and affected by the CSS rule.<\/p>\n<h1 id=\"09f8\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:link | Selects an unvisited <\/code>hyperlink<\/h1>\n<p id=\"32f0\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This selector applies to links that have not been visited. This is mostly used with the <code class=\"\" data-line=\"\">a<\/code> anchor element with href attribute.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"cca3\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">a:link {\n    color: orangered;\n}<\/span><span id=\"c064\" class=\"ku kc dr as kv b fl lc ld le lf lg kx r ky\" data-selectable-paragraph=\"\">&lt;a href=\"\/login\"&gt;Login&lt;a&gt;<\/span><\/pre>\n<p id=\"a7a1\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This will make all <code class=\"\" data-line=\"\">a<\/code> anchor elements with a href attribute that has not been clicked to visit the page in its href attribute to have an orangered color text.<\/p>\n<h1 id=\"4728\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:checked | <\/code>Selects a checked checkbox<\/h1>\n<p id=\"bd3b\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This applies to checkbox that has been checked.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"6844\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">input:checked {\n    border: 2px solid lightcoral;\n}<\/span><\/pre>\n<p id=\"f029\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">This rule applies to all checkboxes that have been clicked on to check it.<\/p>\n<h1 id=\"4729\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:valid | Selects an <\/code>element that is valid<\/h1>\n<p id=\"dcd4\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This is mostly used in forms to visualize form elements that pass validation set by the user. When a validation passes, the defaulting element is set with the <code class=\"\" data-line=\"\">valid<\/code> attribute.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"721a\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">input:valid {\n    boder-color: lightsalmon;\n}<\/span><\/pre>\n<h1 id=\"b8f1\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:invalid | Selects a<\/code>n element that is invalid<\/h1>\n<p id=\"66c1\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">Same as <code class=\"\" data-line=\"\">:valid<\/code> but this will apply to elements that have failed the validation test.<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"06f0\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">input[type=\"text\"]:invalid {\n    border-color: red;\n}<\/span><\/pre>\n<h1 id=\"51bb\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:lang() | Selects an element by a specified lang value<\/code><\/h1>\n<p id=\"8b5e\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">This applies to elements that have their language specified.<\/p>\n<p id=\"2068\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">It can be set in two ways either by this:<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"c40f\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">p:lang(fr) {\n    background: yellow;\n}<\/span><\/pre>\n<p id=\"c91c\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">or<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"fd54\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">p[lang|=\"fr\"] {\n    background: yellow;\n}<\/span><span id=\"a441\" class=\"ku kc dr as kv b fl lc ld le lf lg kx r ky\" data-selectable-paragraph=\"\">&lt;p lang=\"fr\"&gt;Paragraph 1&lt;\/p&gt;<\/span><\/pre>\n<h1 id=\"e1e2\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">:not() | <\/code>Negates the following selections (this is an operator)<\/h1>\n<p id=\"cfec\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">A negation pseudo-selector selects what is not.<\/p>\n<p id=\"da73\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\">Let\u2019s see an example:<\/p>\n<pre class=\"hg hh hi hj hk ks kt ca\"><span id=\"f7b1\" class=\"ku kc dr as kv b fl kw kx r ky\" data-selectable-paragraph=\"\">.innerDiv :not(p) {\n    color: lightcoral;\n}<\/span><span id=\"34f0\" class=\"ku kc dr as kv b fl lc ld le lf lg kx r ky\" data-selectable-paragraph=\"\">&lt;div class=\"innerDiv\"&gt;\n    &lt;p&gt;Paragraph 1&lt;\/p&gt;\n    &lt;p&gt;Paragraph 2&lt;\/p&gt;\n    &lt;div&gt;Div 1&lt;\/div&gt;\n    &lt;p&gt;Paragraph 3&lt;\/p&gt;\n    &lt;div&gt;Div 2&lt;\/div&gt;\n&lt;\/div&gt;<\/span><\/pre>\n<p id=\"c809\" class=\"ix ji dr as iz b ek jl jj em jm jk jc jn ex je jo ey jg jp ez io dj\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">Div 1<\/code> and <code class=\"\" data-line=\"\">Div 2<\/code> will be selected because they are not <code class=\"\" data-line=\"\">p<\/code> elements.<\/p>\n<h1 id=\"3d78\" class=\"kb kc dr as ar kd dt ke dv kf kg kh ki kj kk kl km\" data-selectable-paragraph=\"\">Conclusion<\/h1>\n<p id=\"904e\" class=\"ix ji dr as iz b ek kn jj em ko jk jc kp ex je kq ey jg kr ez io dj\" data-selectable-paragraph=\"\">That\u2019s it. We exhausted the list. There are more pseudoselectors, but they are not standard so I left them out.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Useful CSS pseudo-classes that are often overlooked. Source: CSS Pseudo-Selectors You Might Have Missed &#8211; Bits and Pieces<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2020\/06\/08\/css-pseudo-selectors-you-might-have-missed-bits-and-pieces\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"link","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72,127],"tags":[],"class_list":["post-7323","post","type-post","status-publish","format-link","hentry","category-documentations","category-html","post_format-post-format-link"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-1U7","jetpack-related-posts":[{"id":13395,"url":"https:\/\/monodes.com\/predaelli\/2025\/05\/21\/drop-caps-css-tricks\/","url_meta":{"origin":7323,"position":0},"title":"Drop Caps | CSS-Tricks","author":"Paolo Redaelli","date":"2025-05-21","format":"link","excerpt":"Drop Caps | CSS-Tricks The CSS3 way (no extra markup) Target the first character of the first paragraph using pseudo class selectors. No extra markup needed, but no IE < 9 support. <p> Just a normal sentence. <\/p> p:first-child:first-letter { color: #903; float: left; font-family: Georgia; font-size: 75px; line-height: 60px;\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6373,"url":"https:\/\/monodes.com\/predaelli\/2020\/01\/01\/how-to-style-your-gtk-app-with-css-and-haskell-codeburst\/","url_meta":{"origin":7323,"position":1},"title":"How to Style Your GTK App with CSS and Haskell &#8211; codeburst","author":"Paolo Redaelli","date":"2020-01-01","format":"link","excerpt":"For the upcoming release of Gifcurry \u2014 an open-source, video-to-GIF maker \u2014 a completely custom theme was made using CSS and Haskell. The\u2026 Source: How to Style Your GTK App with CSS and Haskell - codeburst How to Style Your GTK App with CSS and Haskell Lettier Jun 28, 2018\u2026","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"Lettier","src":"https:\/\/i0.wp.com\/miro.medium.com\/fit\/c\/48\/48\/1%2ADM2bfIVj3LLgyG3hMirauw.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8667,"url":"https:\/\/monodes.com\/predaelli\/2021\/09\/08\/useful-tools\/","url_meta":{"origin":7323,"position":2},"title":"Useful tools","author":"Paolo Redaelli","date":"2021-09-08","format":false,"excerpt":"htmlq, like jq, but for HTML. Uses CSS selectors to extract bits content from HTML files. Mozilla's MDN has a good reference for CSS selector syntax. jq is a lightweight and flexible command-line JSON processor.","rel":"","context":"In &quot;Software Libero&quot;","block_context":{"text":"Software Libero","link":"https:\/\/monodes.com\/predaelli\/category\/software\/software-libero\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9530,"url":"https:\/\/monodes.com\/predaelli\/2022\/08\/03\/how-to-create-printer-friendly-pages-with-css\/","url_meta":{"origin":7323,"position":3},"title":"How to Create Printer-friendly Pages with CSS","author":"Paolo Redaelli","date":"2022-08-03","format":"link","excerpt":"How to Create Printer-friendly Pages with CSS How to Create Printer-friendly Pages with CSS CSS Craig BucklerJanuary 5, 2020 Share This article was updated in 2020 to reflect latest best practices in CSS print styling. In this article, we review the art of creating printer-friendly web pages with CSS. \u201cWho\u2026","rel":"","context":"In &quot;Web&quot;","block_context":{"text":"Web","link":"https:\/\/monodes.com\/predaelli\/category\/web\/"},"img":{"alt_text":"Firefox print preview mode","src":"https:\/\/i0.wp.com\/uploads.sitepoint.com\/wp-content\/uploads\/2018\/08\/1577925121printer-friendly-css-05-firefox.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/uploads.sitepoint.com\/wp-content\/uploads\/2018\/08\/1577925121printer-friendly-css-05-firefox.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/uploads.sitepoint.com\/wp-content\/uploads\/2018\/08\/1577925121printer-friendly-css-05-firefox.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":5369,"url":"https:\/\/monodes.com\/predaelli\/2019\/03\/19\/8-useful-css-tricks-parallax-images-sticky-footers-and-more\/","url_meta":{"origin":7323,"position":4},"title":"8 useful CSS tricks: Parallax images, sticky footers and more","author":"Paolo Redaelli","date":"2019-03-19","format":"link","excerpt":"8 useful CSS tricks: Parallax images, sticky footers and more This article shares some of my most satisfying \u201cah-hah!\u201d moments learning CSS, and I hope it can prompt some \u201cah-hah!\u201d moments for you too. Sticky Footer Zoom-on-Hover Images Instant Night Mode Custom Bullet Points Parallax Images Animation with Cropped Images\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/monodes.com\/predaelli\/category\/html\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10190,"url":"https:\/\/monodes.com\/predaelli\/2023\/01\/06\/a-collection-of-popular-layouts-and-patterns-made-with-css-css-layout\/","url_meta":{"origin":7323,"position":5},"title":"A collection of popular layouts and patterns made with CSS &#8211; CSS Layout","author":"Paolo Redaelli","date":"2023-01-06","format":false,"excerpt":"A collection of popular layouts and patterns made with CSS - CSS Layout","rel":"","context":"In &quot;Web&quot;","block_context":{"text":"Web","link":"https:\/\/monodes.com\/predaelli\/category\/web\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/7323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=7323"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/7323\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=7323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=7323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=7323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}