<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amirsina Shadkami</title>
    <description>The latest articles on DEV Community by Amirsina Shadkami (@amirsina).</description>
    <link>https://dev.to/amirsina</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F141121%2F5e566104-eed2-4dc3-bf18-7323f48c4371.jpeg</url>
      <title>DEV Community: Amirsina Shadkami</title>
      <link>https://dev.to/amirsina</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amirsina"/>
    <language>en</language>
    <item>
      <title>Selectors in CSS once and for all!</title>
      <dc:creator>Amirsina Shadkami</dc:creator>
      <pubDate>Thu, 19 Aug 2021 12:44:56 +0000</pubDate>
      <link>https://dev.to/amirsina/selectors-in-css-once-and-for-all-1c68</link>
      <guid>https://dev.to/amirsina/selectors-in-css-once-and-for-all-1c68</guid>
      <description>&lt;p&gt;A question/problem that many may have faced while “learning/working” is that they are dubious or mistaken about choosing a selector. Since they don’t know which selector to use, they get stuck in an irritating loop and after trying to work it out for some time, they end up backing down from this idea and instead turn to DOM Manipulation using JavaScript or even worse, changing the DOM Structure!&lt;br&gt;
CSS has quite a variety of selectors but not all of them are used regularly in practice. Some have a specific usage that can be determined by their names and others remain a mystery but you don’t need to know ’em all. The purpose of this article is to point out and explain the most useful selectors once and for all!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can see a general diagram of the most used and important selectors below but before we talk about them you should know that I have not mentioned the class and ID selector ( ‘ . ‘ , ‘ # ‘ ). So if you don’t already know about these two, instead of reading this article I recommend you to start with the basics of CSS.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;1 ) Descendant selector&lt;/p&gt;

&lt;p&gt;To use this one you don’t need to use a specific character. It is the space between elements and it selects all the descendants of the element in question.&lt;/p&gt;

&lt;p&gt;Imagine we have :&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ur2zc845ln94txnbrbs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ur2zc845ln94txnbrbs.png" alt="Descendant selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frrb9nos6uwiz3tz9kf6o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frrb9nos6uwiz3tz9kf6o.png" alt="Descendant selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Question: Which paragraph is the style applied to?&lt;br&gt;
Answer: To all&lt;br&gt;
When you are using the descendant selector, indentation of the elements is not important and they only need to be a descendant of the main wrapper.&lt;/p&gt;

&lt;p&gt;So even in the situation below, the styles will be applied to the paragraphs as long as they are descendants of “post”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnri3xzb6idnm4fhzzfvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnri3xzb6idnm4fhzzfvv.png" alt="Descendant selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Direct child selector (&amp;gt;)&lt;/p&gt;

&lt;p&gt;Only the elements that are directly mentioned as a child to the parent element are selected, not the ones that are inside a second or third wrapper element.&lt;br&gt;
Look at the last example rewritten with the direct child selector:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxhjbv85a0xr4cxlrr7gh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxhjbv85a0xr4cxlrr7gh.png" alt="Direct child selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv9pmd5far5rxwk50zpg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv9pmd5far5rxwk50zpg.png" alt="Direct child selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Question: Which paragraph is the style applied to?&lt;br&gt;
Answer: The first paragraph after the section tag and the last one before closing the section tag&lt;/p&gt;

&lt;p&gt;3) Sibling selector&lt;/p&gt;

&lt;p&gt;3.1) General Sibling Selector (~)&lt;br&gt;
After using this selector, all the elements on the right side of “~” (Which are of the same kind) are selected, ONLY IF they have the same parent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70ykopi7xmd7b4zguuh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70ykopi7xmd7b4zguuh5.png" alt="General Sibling Selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsb8ttxhifq380aq26c05.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsb8ttxhifq380aq26c05.png" alt="General Sibling Selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Question: Which paragraph is the style applied to?&lt;br&gt;
Answer: paragraph 19&lt;br&gt;
The selected paragraphs must:&lt;br&gt;
Come after the element “H1”&lt;br&gt;
Have the same parent as “H1”&lt;br&gt;
Since the two conditions above are not true for paragraphs 1, 5, 9, 15, and 23 the style will not be applied to them.&lt;br&gt;
Why?Lines 1, 5, 9: They are placed before “H1”.&lt;br&gt;
Lines 15, 23: Although they come after “H1”, they don’t have the same parent as “H1”.&lt;/p&gt;

&lt;p&gt;3.2) Adjacent sibling selector (+)&lt;br&gt;
Using this selector, we only select the first element on the right side of “+”. So if we used this selector in the last example, none of the paragraphs would be selected. But if we had a number of paragraphs right after “H1”, no matter how many, only the first one would be selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wayl7ua2r4g9gi22j0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wayl7ua2r4g9gi22j0g.png" alt="Adjacent sibling selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqq1qwqrujz5y5yfslts9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqq1qwqrujz5y5yfslts9.png" alt="Adjacent sibling selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Question: Which paragraph is the style applied to?&lt;br&gt;
Answer: Just the one after “H1” (paragraph 14)&lt;/p&gt;

&lt;p&gt;4) Attribute Present Selector&lt;br&gt;
HTML tags have lots of attributes which we can use in CSS.&lt;br&gt;
For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnkjlourkn7e63a9agit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnkjlourkn7e63a9agit.png" alt="Attribute Present Selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyif57yjo2ttt4htvti5u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyif57yjo2ttt4htvti5u.png" alt="Attribute Present Selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the examples above we’ve used the “href”, “type”, and “id” attributes but we can use others like “form” or “input” or etc.&lt;br&gt;
The characters &lt;code&gt;$, ^, *&lt;/code&gt; may seem a bit confusing but wait a second:&lt;br&gt;
^= : The attribute selected for the used element starts with what is inside (‘ ‘)&lt;/p&gt;

&lt;p&gt;*= : The attribute selected for the used element includes what’s inside (‘ ‘)&lt;/p&gt;

&lt;p&gt;$= : The attribute selected for the used element ends with what is inside (‘ ‘)&lt;/p&gt;

&lt;p&gt;Let’s take another look at the example:&lt;br&gt;
In the first item we just used the equal sign and it contains “&lt;a href="https://medium.com%E2%80%9D" rel="noopener noreferrer"&gt;https://medium.com”&lt;/a&gt;. This selector picks the “a” tags that exactly contain medium’s href.&lt;br&gt;
In the second item the “a” tags that their href begins with ‘&lt;a href="https://nest%E2%80%99" rel="noopener noreferrer"&gt;https://nest’&lt;/a&gt; are selected.&lt;br&gt;
In the third item the “a” tags that their href ends in. ‘.org’ are selected.&lt;br&gt;
In the fourth item the “a” tags that their href contains ‘docker’ are selected.&lt;br&gt;
In the fifth item ‘I’ type ol lists are selected.&lt;br&gt;
In the sixth item the span inside div with the ID “unique_div” is selected.&lt;/p&gt;

&lt;p&gt;5) pseudo-classes&lt;br&gt;
pseudo-classes are used at times when we need to have access to an element in a certain state or situation. Below we are going to discuss 8 of the most used ones.&lt;/p&gt;

&lt;p&gt;5.1) link pseudo classes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a:link {…} ~&amp;gt; Links that have not been visited and are in their normal state.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a:visited {…} ~&amp;gt; Links that have been visited.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.2) User action pseudo classes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a:active‌ {…} ~&amp;gt; the link that is active now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:hover {…} ~&amp;gt; the element which the cursor is on now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:focus {…} ~&amp;gt; the element that is touched right now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.3) User interface pseudo classes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input:enabled {…} ~&amp;gt; active inputs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input:disabled {…} ~&amp;gt; inactive inputs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input:checked {…} ~&amp;gt; checked checkboxes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input:indeterminate {…} ~&amp;gt; when there are no changes applied to a radio box or a select box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.4) Structural &amp;amp; Position Pseudo-classes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:first-child {…} ~&amp;gt; selects the first child
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:last-child {…} ~&amp;gt; selects the last child
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:first-of-type {…} ~&amp;gt; the first child of a parent from a specific element
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:last-of-type {…} ~&amp;gt; the last child of a parent from a specific element
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element:only-child {…} ~&amp;gt; the child is selected only if it’s the only child to the parent element
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you find it a bit difficult to understand “only-child” look at the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div span:only-child {
  color: firebrick;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;span&amp;gt;Text&amp;lt;/span&amp;gt;
    &amp;lt;span&amp;gt;Text&amp;lt;/span&amp;gt;
    &amp;lt;div&amp;gt;
      &amp;lt;span&amp;gt;This will be selected&amp;lt;/span&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only selected span is the one that is div’s only child.&lt;/p&gt;

&lt;p&gt;5.5) Numbers &amp;amp; Expressions Pseudo-classes&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Element:nth-child(n) : The nth child is directly selected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Element:nth-child(an) : The child’s of the multiples of ‘a’ &lt;br&gt;
are selected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Element:nth-child(n+b) : This one’s a bit different. Considering b’s value, the children are selected starting from b itself and on.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li:nth-child(n + 4) ~&amp;gt; Selected from the fourth 'li' onwards (the fourth item itself is also selected)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Element:nth-child(an+b) : Here, n starts from 0 and after getting multiplied by a, it’s added to b and then the children are selected.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li:nth-child(4n+7){...} ~&amp;gt;(4×0)+7, (4×1)+7, (4×2)+7 = children 11 and 15 are selected.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Element:nth-child(an-b) : Here too, n starts from 0 and after getting multiplied by a, b is subtracted.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li:nth-child(6n-4){...} ~&amp;gt; (6×0)-4, (6×1)-4, (6×2)-4 = children 2, 8, and 14 are selected
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.6)Empty Pseudo-class&lt;/p&gt;

&lt;p&gt;Here, elements are selected that are either empty or containing just a comment. But notice that since space and tab are strings they are not considered as empty.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#post span:empty {…}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section id=”post”&amp;gt;
  &amp;lt;span&amp;gt;&amp;lt;/span&amp;gt; ~&amp;gt; This will be selected
  &amp;lt;span&amp;gt; &amp;lt;/span&amp;gt; ~&amp;gt; This will not be selected (because of space)
  &amp;lt;span&amp;gt;&amp;lt;!--comment--&amp;gt;&amp;lt;/span&amp;gt; ~&amp;gt; This will be selected
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.7)Negation Pseudo-class&lt;/p&gt;

&lt;p&gt;As you can probably guess by the name, this selector does not include the elements mentioned inside ( :not() )&lt;br&gt;
An interesting thing about this selector is that it can be combined with the previous ones, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li:not(.li-elements) {…} ~&amp;gt; a list of items not including the mentioned class
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ul li:not(:nth-child(2n)) {…} ~&amp;gt; a list of items are selected that are not multiples of 2.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.8) Textual Pseudo-elements&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element::after {…} ~&amp;gt; using this selector, a pseudo element is added to the end of the selected element, which can have content or/and style. It’s usually used to add an animation or icon for complementary purposes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element::before {…} ~&amp;gt; This one is like after, with the only difference being the pseudo elements positioning moved to the beginning of the selected element.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element::first-letter {…} ~&amp;gt; The first textual character inside our specific element is selected. You must have seen this one in publications websites.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element::first-line {…} ~&amp;gt; selects the first line of the specific element.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element::placeholder {…} ~&amp;gt; If the specific element has a placeholder, it’s selected and you can add a style to it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Element::selection {…} ~&amp;gt; when you select a text in a web page, the selected piece of text has a certain color and background color. Depending on the OS’s user agent there’s a default accent color, for example, it’s blue and white for Windows, orange and white for Ubuntu, and macOS white. 
Bottomline being, this color is changeable and this is made possible using this selector.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;::selection {
  background:#0f94e9;
  color:#fff
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9werxdxvhnfpk8e22h99.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9werxdxvhnfpk8e22h99.jpeg" alt="Element selection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1727ymz7sjzhge6qdog.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1727ymz7sjzhge6qdog.jpeg" alt="Element selection"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>style</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
