<?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: Gajendra Dhir</title>
    <description>The latest articles on DEV Community by Gajendra Dhir (@gajendra).</description>
    <link>https://dev.to/gajendra</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%2F1639926%2F82acbbe4-044a-4b1b-b027-7d56597a6c02.jpg</url>
      <title>DEV Community: Gajendra Dhir</title>
      <link>https://dev.to/gajendra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gajendra"/>
    <language>en</language>
    <item>
      <title>Selectors in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Fri, 13 Dec 2024 12:31:45 +0000</pubDate>
      <link>https://dev.to/gajendra/selectors-in-css-2l14</link>
      <guid>https://dev.to/gajendra/selectors-in-css-2l14</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Selector is the first part of any CSS rule. The selector identifies to which part or section of the HTML document the rule will be applied.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;selector&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="py"&gt;property&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="err"&gt;....&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule is enclosed in &lt;code&gt;{  }&lt;/code&gt;. A rule allows us to specify on or more properties and their values that decides how it will render.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Selectors
&lt;/h2&gt;

&lt;p&gt;Select elements based on name, id, class&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;name&lt;/code&gt; of element
&lt;/h3&gt;

&lt;p&gt;The name of the element is directly used as the selector.&lt;/p&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;id&lt;/code&gt; of element
&lt;/h3&gt;

&lt;p&gt;In HTML, some elements can be identified with the &lt;code&gt;id&lt;/code&gt; attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'idname'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a some text.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CSS, the selector for this will start with a hash (&lt;code&gt;#&lt;/code&gt;) followed by the name of the id.&lt;/p&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nf"&gt;#idname&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;class&lt;/code&gt; of element
&lt;/h3&gt;

&lt;p&gt;In HTML, when you may define a class attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'container'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CSS, the selector for the class starts with a period (&lt;code&gt;.&lt;/code&gt;) followed by the name of the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multiple class names can be marked in HTML by seperating them with a space.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'card card-info'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When multiple classes are defined, then the styling rules will apply in the order they are listed. The latest value for a property will prevail if the property values are given in more than one class.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attribute Selector
&lt;/h2&gt;

&lt;p&gt;Attribute selector matches elements based on the value of some of its attribute.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;[attr]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr=value]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr~=value]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr|=value]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr^=value]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr$=value]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr*=value]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr operator value i]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;[attr operator value s]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;.&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; are special operators to identify the attributes id and class. &lt;code&gt;[]&lt;/code&gt; allow to select any attribute.&lt;/p&gt;

&lt;p&gt;Some examples...&lt;br&gt;
| selector | description |&lt;br&gt;
|-|-|&lt;br&gt;
| &lt;code&gt;a[target]&lt;/code&gt; | any element &lt;code&gt;a&lt;/code&gt; having a &lt;code&gt;target&lt;/code&gt; attribute |&lt;br&gt;
| &lt;code&gt;a[target='_blank']&lt;/code&gt; | any anchor element having target = _blank |&lt;br&gt;
| &lt;code&gt;div[class\|="card"]&lt;/code&gt; | any div with class having value the whole word &lt;code&gt;card&lt;/code&gt; or &lt;code&gt;card&lt;/code&gt; followed by &lt;code&gt;-&lt;/code&gt;, like &lt;code&gt;card-head&lt;/code&gt; or &lt;code&gt;card-body&lt;/code&gt; |&lt;br&gt;
| &lt;code&gt;div[class^="card"]&lt;/code&gt; | any div with class whose value starts with &lt;code&gt;card&lt;/code&gt; |&lt;br&gt;
| &lt;code&gt;div[class$="head"]&lt;/code&gt; | any div with class whose value ends with &lt;code&gt;head&lt;/code&gt; |&lt;br&gt;
| &lt;code&gt;div[class*="card"]&lt;/code&gt; | any div with class having value contains the string &lt;code&gt;card&lt;/code&gt; anywhere |&lt;/p&gt;
&lt;h2&gt;
  
  
  Selector List - Comma (&lt;code&gt;,&lt;/code&gt;) separated
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.card-info&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If the same styling is to be applied to multiple selectors then use comma (&lt;code&gt;,&lt;/code&gt;) to separate the selectors and then define the css rule.&lt;/p&gt;
&lt;h2&gt;
  
  
  Combinators
&lt;/h2&gt;

&lt;p&gt;A combinator is a combination of two or more selectors used together. Combinators are used define the specificity of the selector.&lt;/p&gt;
&lt;h3&gt;
  
  
  Descendant Selector (space)
&lt;/h3&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will select all &lt;code&gt;p&lt;/code&gt;s &lt;em&gt;under&lt;/em&gt; all &lt;code&gt;div&lt;/code&gt;s. &lt;code&gt;p&lt;/code&gt;s in any child of the &lt;code&gt;div&lt;/code&gt;s will also be included.&lt;/p&gt;

&lt;h3&gt;
  
  
  Child Selector (&amp;gt;)
&lt;/h3&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will select all &lt;code&gt;p&lt;/code&gt;s &lt;em&gt;directly under&lt;/em&gt; all &lt;code&gt;div&lt;/code&gt;s. &lt;code&gt;p&lt;/code&gt;s nested inside any child of &lt;code&gt;div&lt;/code&gt; will not be included.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adjacent Sibling Selector (+)
&lt;/h3&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will select &lt;code&gt;p&lt;/code&gt;s that are &lt;em&gt;immediately&lt;/em&gt; after &lt;code&gt;div&lt;/code&gt;s - at the same level. No parent or child will be included.&lt;/p&gt;

&lt;h3&gt;
  
  
  General Sibling Selector (~)
&lt;/h3&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will select &lt;code&gt;p&lt;/code&gt;s that are &lt;em&gt;anywhere&lt;/em&gt; after &lt;code&gt;div&lt;/code&gt;s - at the same level. No parent or child will be included.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nested Selector (with and without &lt;code&gt;&amp;amp;&lt;/code&gt;)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  preceding selector with &amp;amp;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
        &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;:nested&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
            &lt;span class="err"&gt;...&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;evaluates to...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;parent&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;.parent&lt;/span&gt;&lt;span class="nd"&gt;:nested&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...child&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;all &lt;code&gt;.parent&lt;/code&gt; having puesdo-class &lt;code&gt;:nested&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  without &amp;amp;
&lt;/h3&gt;

&lt;p&gt;When the selector is nested without &lt;code&gt;&amp;amp;&lt;/code&gt;, a space is added to the resulting nested css-rule, i.e.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;parent&lt;/span&gt; &lt;span class="py"&gt;rules&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;nested&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt; &lt;span class="n"&gt;rules&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;evaluates to...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;parent&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;:nested&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...child&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;all descendants of &lt;code&gt;.parent&lt;/code&gt; having puesdo-class &lt;code&gt;:nested&lt;/code&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  adding &amp;amp; after the selector
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.outer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;outer&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
        &lt;span class="err"&gt;.nested&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
            &lt;span class="err"&gt;...nested&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;evaluates to...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.outer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;outer&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;.nested&lt;/span&gt; &lt;span class="nc"&gt;.outer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...nested&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here outer rules will apply normally apply &lt;code&gt;.outer&lt;/code&gt; selector, but when &lt;code&gt;.outer&lt;/code&gt; is a descendant of the &lt;code&gt;.nested&lt;/code&gt; selector then  the nested rules will apply.&lt;/p&gt;

&lt;h3&gt;
  
  
  adding multiple &amp;amp; after the selector
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;parent&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
        &lt;span class="err"&gt;.nested&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
            &lt;span class="err"&gt;...nested&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the three &lt;code&gt;&amp;amp;&lt;/code&gt;s evaluate to...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;parent&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;.nested&lt;/span&gt; &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...child&lt;/span&gt; &lt;span class="err"&gt;rules&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pseudo-classes
&lt;/h2&gt;

&lt;p&gt;Pseudo-classes are selectors that are recognized in the browser without explicitly being defined in the web-page.&lt;/p&gt;

&lt;p&gt;A pseudo-class can used by adding &lt;code&gt;:&lt;/code&gt; before it.&lt;/p&gt;

&lt;p&gt;eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt;          &lt;span class="c"&gt;/* active links */&lt;/span&gt;
  &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;         &lt;span class="c"&gt;/* when mouse hovers over the &amp;lt;div&amp;gt; */&lt;/span&gt;
  &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:first-child&lt;/span&gt;   &lt;span class="c"&gt;/* the first child inside the &amp;lt;div&amp;gt; */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  List of Pseudo-classes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;:active&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:any-link&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:dir&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:empty&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:has&lt;/code&gt;(&lt;em&gt;selector&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:hover&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:is&lt;/code&gt;(&lt;em&gt;selector&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:lang&lt;/code&gt;(&lt;em&gt;language&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:link&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:not&lt;/code&gt;(&lt;em&gt;selector&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:root&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:state&lt;/code&gt;(&lt;em&gt;identifier&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:target&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:visited&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:where&lt;/code&gt;(&lt;em&gt;selector&lt;/em&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;for child&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;:first-child&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:last-child&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:nth-child&lt;/code&gt;(&lt;em&gt;position&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:nth-last-child&lt;/code&gt;(&lt;em&gt;position&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:only-child&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;for of-type&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;:first-of-type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:last-of-type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:nth-of-type&lt;/code&gt;(&lt;em&gt;position&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:nth-last-of-type&lt;/code&gt;(&lt;em&gt;position&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:only-of-type&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;for inputs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;:checked&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:disabled&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:enabled&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:focus&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:focus-visible&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:in-range&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:inderminate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:invalid&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:optional&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:out-of-range&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:read-only&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:read-write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:required&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:valid&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CSS Pseudo Elements
&lt;/h2&gt;

&lt;p&gt;Pseudo Elements do not have to be defined in the web-page, yet the browser recognizes these elements.&lt;/p&gt;

&lt;h3&gt;
  
  
  List of pseudo elements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;::after&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::before&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::file-selector-button&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::first-letter&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::first-line&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::grammar-error&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::marker&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::placeholder&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::selection&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::spelling-error&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::target-text&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::backdrop&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::cue&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::highlight&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::part&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::slotted&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::view-transition&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::view-transition-image-pair()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::view-transition-group()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::view-transition-new()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::view-transition-old()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope you find this useful.&lt;/p&gt;

</description>
      <category>selectors</category>
      <category>nested</category>
      <category>pseudoclasses</category>
      <category>pseudoelements</category>
    </item>
    <item>
      <title>Flex Box Layout in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Tue, 12 Nov 2024 06:31:01 +0000</pubDate>
      <link>https://dev.to/gajendra/flex-box-layout-in-css-p46</link>
      <guid>https://dev.to/gajendra/flex-box-layout-in-css-p46</guid>
      <description>&lt;p&gt;The &lt;strong&gt;FlexBox layout&lt;/strong&gt; is initiated with the &lt;code&gt;display: flex;&lt;/code&gt; property and you can control how the children of the element are laid-out inside the parent on the webpage.&lt;/p&gt;

&lt;p&gt;The flexbox layout plays probably plays a very important role in planning a responsive web layout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;CSS&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;other&lt;/span&gt; &lt;span class="err"&gt;properties&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the display property, the flex value can be along with inline (&lt;code&gt;display: inline flex&lt;/code&gt; or &lt;code&gt;display: inline-flex&lt;/code&gt;) to define inline flex containers and with block (&lt;code&gt;display: block flex&lt;/code&gt; or &lt;code&gt;display: block-flex&lt;/code&gt;) to define block flex containers. &lt;code&gt;flex&lt;/code&gt; used by itself defines a block level container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;(HTML)
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'parent'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'child1'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        ...content of child 1
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'child2'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        ...content of child 2
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    ....
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each item inside a flexbox is called &lt;em&gt;flex item&lt;/em&gt; and the flexbox itself is referred to as the &lt;em&gt;flex container&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;The layout of flex items can be in either horizontal or vertical direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main Axis and Cross Axis
&lt;/h2&gt;

&lt;p&gt;The direction in the items are laid out is known as the &lt;em&gt;main axis&lt;/em&gt; and the direction perpendicular to the main axis is known as the &lt;em&gt;cross axis&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;By default, &lt;code&gt;row&lt;/code&gt; is the main axis, this can be changed by specifying the desired &lt;code&gt;flex-direction&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The size of a flex item along the main axis is identified as the &lt;em&gt;main size&lt;/em&gt;, where as its size along the cross axis is the  &lt;em&gt;cross size&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Properties for the flexbox
&lt;/h2&gt;

&lt;p&gt;Flexbox has properties some applicable at the parent and while others at the child levels that can be used to create innovative layouts. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parent Level Properties&lt;/th&gt;
&lt;th&gt;Child Level Properties&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;flex-direction&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;flex-grow&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;flex-wrap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;flex-shrink&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;justify-content&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;flex-basis&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;justify-items&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;justify-self&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;align-content&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;align-self&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;align-items&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;order&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;column-gap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;row-gap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Shorthands&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;flex-flow&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;flex&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;place-content&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;place-self&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;place-items&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;gap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  At parent (or container) level...
&lt;/h3&gt;

&lt;p&gt;Here are the properties that must be specified for the container element to control the flow of flex items in it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;flex-direction&lt;/code&gt; &lt;a id="flexdirection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;determines the direction in which the successive items is to placed in the flex container.&lt;/p&gt;

&lt;p&gt;When the direction is &lt;code&gt;row&lt;/code&gt; or &lt;code&gt;row-reverse&lt;/code&gt; the main axis is in the horizontal direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F25hbsim45a6wq83py02b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F25hbsim45a6wq83py02b.png" alt="Flex Row" width="440" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, when the direction is &lt;code&gt;column&lt;/code&gt; or &lt;code&gt;column-reverse&lt;/code&gt; the main axis is in the vertical direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fbyn42fp6h9tleml35plj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fbyn42fp6h9tleml35plj.png" alt="Flex Column" width="440" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Note&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When flex-direction: row, then default &lt;code&gt;width&lt;/code&gt; of container is &lt;code&gt;100%&lt;/code&gt;, and &lt;/p&gt;

&lt;p&gt;When flex-direction: column, the default &lt;code&gt;height&lt;/code&gt; is the height required to render the content.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;flex-wrap&lt;/code&gt; &lt;a id="flexwrap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;determines whether are items will be laid out on one line or may flow onto multiple lines.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;flex-flow&lt;/code&gt; &lt;a id="flexflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the shorthand property for...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;flex-direction&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;flex-wrap&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;justify-content&lt;/code&gt; &lt;a id="justifycontent"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;justifies the overall content along the &lt;strong&gt;main axis&lt;/strong&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;justify-items&lt;/code&gt; &lt;a id="justifyitems"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;sets the justification of the individual elements along the main axis within the dimensions designated to it after &lt;code&gt;justify-content&lt;/code&gt; is processed.&lt;/p&gt;

&lt;p&gt;This setting applies to each of the elements in the flexbox, unless a &lt;code&gt;justify-self&lt;/code&gt; is specified at the child level.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;align-content&lt;/code&gt; &lt;a id="aligncontent"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aligns the overall content along the &lt;strong&gt;cross axis&lt;/strong&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;align-items&lt;/code&gt; &lt;a id="alignitems"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aligns the individual elements along the cross axis within the dimensions designated to it after &lt;code&gt;align-content&lt;/code&gt; is processed.&lt;/p&gt;

&lt;p&gt;This alignment is applied to each of element in the flexbox, unless a &lt;code&gt;align-self&lt;/code&gt; is specified at the child level.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;place-content&lt;/code&gt;&lt;a id="placecontent"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a shorthand property for &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;align-content&lt;/code&gt;, and &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;justify-content&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If one value is provided, that value applied to both &lt;code&gt;align-content&lt;/code&gt; and &lt;code&gt;justify-content&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If two values are provided, the first will be for &lt;code&gt;align-content&lt;/code&gt; and the second will be for &lt;code&gt;justify-content&lt;/code&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;place-items&lt;/code&gt; &lt;a id="placeitems"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a shorthand property for &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;align-items&lt;/code&gt; and&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;justify-items&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If one value is provided, that value applied to both &lt;code&gt;align-items&lt;/code&gt; and &lt;code&gt;justify-items&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If two values are provided, the first will be for &lt;code&gt;align-items&lt;/code&gt; and the second will be for &lt;code&gt;justify-items&lt;/code&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;column-gap&lt;/code&gt;&lt;a id="columngap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Determines the gap between columns in the &lt;code&gt;flex&lt;/code&gt; box. Also works for &lt;code&gt;grid&lt;/code&gt; and &lt;code&gt;multi-column&lt;/code&gt; container.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;row-gap&lt;/code&gt;&lt;a id="rowgap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Determines the gap between rows in the &lt;code&gt;flex&lt;/code&gt; and &lt;code&gt;grid&lt;/code&gt; containers&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;gap&lt;/code&gt;&lt;a id="gap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the shorthand property for...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;column-gap&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;row-gap&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  At child level...
&lt;/h3&gt;

&lt;p&gt;Below are the properties that may be specified to control the rendering of the flex items.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;flex&lt;/code&gt;&lt;a id="flex"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is shorthand property for...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;flex-grow&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;flex-shrink&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;flex-basis&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;flex-grow&lt;/code&gt; &lt;a id="flexgrow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This determines how the &lt;em&gt;positive free space&lt;/em&gt; in the flex container is assigned to the &lt;em&gt;main-size&lt;/em&gt; of the item i.e. it specifies the grow factor for an item.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;flex-shrink&lt;/code&gt; &lt;a id="flexshrink"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This determines how the &lt;em&gt;negative free space&lt;/em&gt; in the flex container is assigned to the &lt;em&gt;main-size&lt;/em&gt; of the item i.e. it specifies the shrink factor for an item.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;flex-basis&lt;/code&gt; &lt;a id="flexbasis"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This specifies the initial main size for the flex item. The final computed main size will depend when the &lt;code&gt;flex-grow&lt;/code&gt; and &lt;code&gt;flex-shrink&lt;/code&gt; values are applied to this.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;justify-self&lt;/code&gt;&lt;a id="justifyself"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This property overrides the &lt;code&gt;justify-items&lt;/code&gt; property defined for the flex container.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;align-self&lt;/code&gt;&lt;a id="alignself"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This property overrides the &lt;code&gt;align-items&lt;/code&gt; property defined for the flex container.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;place-self&lt;/code&gt;&lt;a id="placeself"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This property overrides the &lt;code&gt;place-items&lt;/code&gt; property values provided for the flex container.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;order&lt;/code&gt; &lt;a id="order"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;order&lt;/code&gt; property defines the sequence in which each flex item is rendered.&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://gajendhir.github.io/csspages/" rel="noopener noreferrer"&gt;&lt;img src="https://media2.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%2Fm0zaupiajg1nj6y0hvrt.png" alt="Logo for csspages" width="200" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>justify</category>
      <category>align</category>
      <category>flexbox</category>
    </item>
    <item>
      <title>Coordinate System in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Mon, 11 Nov 2024 09:36:20 +0000</pubDate>
      <link>https://dev.to/gajendra/coordinate-system-in-css-43bf</link>
      <guid>https://dev.to/gajendra/coordinate-system-in-css-43bf</guid>
      <description>&lt;p&gt;Two dimensional (x, y) coordinates or three dimensional (x, y, z) coordinates are used to indicate the location of a pixel in a graphics context. &lt;/p&gt;

&lt;h2&gt;
  
  
  Dimensions and Origin
&lt;/h2&gt;

&lt;h3&gt;
  
  
  x-coordinate
&lt;/h3&gt;

&lt;p&gt;indicates the location on the horizontal axis&lt;/p&gt;

&lt;h3&gt;
  
  
  y-coordinate
&lt;/h3&gt;

&lt;p&gt;indicates the location on the vertical axis&lt;/p&gt;

&lt;h3&gt;
  
  
  z-coordinate
&lt;/h3&gt;

&lt;p&gt;indicates the position along views - to - screen axis. &lt;/p&gt;

&lt;p&gt;z-axis coordinates are handled differently for showing a graphic shape in 3d or for rendering layers of elements one on top of the other in the 2d mode.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;z-index&lt;/code&gt; property is used to decide which element will be shown above or below other overlapping elements. The element with the lowest z-index is recognized as the topmost layer and will be shown above all others.&lt;/p&gt;

&lt;h3&gt;
  
  
  Origin
&lt;/h3&gt;

&lt;p&gt;The position of each point is defined relative to a fixed point in the context. This fixed point is called &lt;strong&gt;Origin&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In a browser, the default point of origin is the top-left corner of the context. The point below this origin is moves in the positive y direction and to the left of the origin moves in the positive x direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Graphic Contexts
&lt;/h2&gt;

&lt;p&gt;CSSOM (CSS Object Model) maintains coordinates on 4 graphics contexts...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fow261bvdfz312lyd5zqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fow261bvdfz312lyd5zqk.png" alt="Co-ordinate Systems" width="485" height="686"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a browser renders a page, the coordinates of each pixel is maintains in 4 contexts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Offset for Elements
&lt;/h3&gt;

&lt;p&gt;The position of the pixel within the element is called its &lt;strong&gt;&lt;code&gt;Offset&lt;/code&gt;&lt;/strong&gt;. ie. if it is the point along the x and y axes when we consider the top-left point of the element as the origin.&lt;/p&gt;

&lt;h3&gt;
  
  
  Client for Viewport
&lt;/h3&gt;

&lt;p&gt;The part of the browser dedicated to displaying the webpage being being rendered is known as the &lt;strong&gt;&lt;code&gt;Viewport&lt;/code&gt;&lt;/strong&gt;. The location of a pixel with reference to the viewport is called its position on the &lt;code&gt;Client&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The viewport is generally a part of the screen and displays a part of the webpage. If the page is bigger than the viewport, scrollbars are used to control which part of the page is visible in the viewport.&lt;/p&gt;

&lt;h3&gt;
  
  
  Page
&lt;/h3&gt;

&lt;p&gt;Page is the entire rendered document. Any coordinate on the page coordinate system will always be same...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no matter how much it has been scrolled. &lt;/li&gt;
&lt;li&gt;no matter where it is visible to the user or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By default, &lt;code&gt;Page&lt;/code&gt; coordinates give the position where the top-left corner of the page is considered the origin.&lt;/p&gt;

&lt;h3&gt;
  
  
  Screen
&lt;/h3&gt;

&lt;p&gt;Screen is the entire physical device on which the document is presented. A single point on the Screen will correspond to the different points on the Viewport if the Viewport is moved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coordinates in Event Handling
&lt;/h2&gt;

&lt;h3&gt;
  
  
  MouseClick Event
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;MouseClick.OffsetX&lt;/code&gt; and &lt;code&gt;MouseClick.OffsetY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MouseClick.ClientX&lt;/code&gt; and &lt;code&gt;MouseClick.ClientY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MouseClick.PageX&lt;/code&gt; and &lt;code&gt;MouseClick.PageY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MouseClick.ScreenX&lt;/code&gt; and &lt;code&gt;MouseClick.ScreenY&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These coordinates are generally used in Javascript to find-out where the user clicked the mouse while browsing and respond accordingly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Touch Event
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Touch.ClientX&lt;/code&gt; and &lt;code&gt;Touch.ClientY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Touch.PageX&lt;/code&gt; and &lt;code&gt;Touch.PageY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Touch.ScreenX&lt;/code&gt; and &lt;code&gt;Touch.ScreenY&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These coordinates are generally used in Javascript to find-out where the user touched on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transform the coordinates
&lt;/h2&gt;

&lt;p&gt;CSS provides properties that allow you to alter the position of the axis for coordinates of elements i.e. the coordinates of certain elements can be transformed. &lt;/p&gt;

&lt;p&gt;The transform operations supported are...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;transform-origin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rotate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scale&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;translate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skew&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;perspective&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of the transformations work in 3d mode also. The &lt;code&gt;transform&lt;/code&gt; property is used to deliver some of the most render some of the popular animation sequences in CSS.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Size of box in CSS (box-sizing)</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Mon, 14 Oct 2024 12:24:22 +0000</pubDate>
      <link>https://dev.to/gajendra/size-of-box-in-css-box-sizing-54m0</link>
      <guid>https://dev.to/gajendra/size-of-box-in-css-box-sizing-54m0</guid>
      <description>&lt;p&gt;The layout of elements is done by marking the position and dimension of each element as rectangular boxes in the document, based on the CSS Box Model. &lt;/p&gt;

&lt;p&gt;The size and space required for each rectangular box on the document is a very important consideration in any UI design project.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;box-sizing: content-box&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Consider the following CSS rule...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size of the &lt;em&gt;content-area&lt;/em&gt; for &lt;code&gt;.box&lt;/code&gt; will be...&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;property&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;width&lt;/td&gt;
&lt;td&gt;&lt;code&gt;150px&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;height&lt;/td&gt;
&lt;td&gt;&lt;code&gt;100px&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;and, the space required by it on the document will be...&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;property&lt;/th&gt;
&lt;th&gt;computation&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;width&lt;/td&gt;
&lt;td&gt;&lt;code&gt;10 + 2 + 5 + 150 + 5 + 2 + 10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;184px&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;height&lt;/td&gt;
&lt;td&gt;&lt;code&gt;10 + 2 + 5 + 100 + 5 + 2 + 10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;134px&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;To compute of space for margins, one must take into consideration the impact of &lt;code&gt;margin-collapse&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;box-sizing: border-box&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Now, check this rule...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the size of the &lt;em&gt;content-area&lt;/em&gt; for &lt;code&gt;.box&lt;/code&gt; will be...&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;property&lt;/th&gt;
&lt;th&gt;computation&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;width&lt;/td&gt;
&lt;td&gt;&lt;code&gt;150 - 5 - 2 - 5 - 2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;136px&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;height&lt;/td&gt;
&lt;td&gt;&lt;code&gt;100 - 5 - 2 - 5 - 2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;86px&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;and, the space required by the element on the document will be...&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;property&lt;/th&gt;
&lt;th&gt;computation&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;width&lt;/td&gt;
&lt;td&gt;&lt;code&gt;10 + 150 + 10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;170px&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;height&lt;/td&gt;
&lt;td&gt;&lt;code&gt;10 + 100 + 10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;120px&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How does this work?
&lt;/h2&gt;

&lt;p&gt;An understanding of the Box Model goes a long way in achieving the desired UI/UX.&lt;/p&gt;

&lt;h3&gt;
  
  
  Areas and Boxes
&lt;/h3&gt;

&lt;p&gt;The rectangular box for every element has 4 areas or parts...&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%2F7sisxfdrl4we75ytt8bo.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%2F7sisxfdrl4we75ytt8bo.png" alt="Box Model in CSS" width="350" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  content-area
&lt;/h4&gt;

&lt;p&gt;This is the area where the actual content - text, images or other HTML elements - are displayed. &lt;/p&gt;

&lt;h4&gt;
  
  
  padding-area
&lt;/h4&gt;

&lt;p&gt;specified using &lt;code&gt;padding&lt;/code&gt; or the &lt;code&gt;padding-*&lt;/code&gt; sub-properties.&lt;/p&gt;

&lt;p&gt;This is the area that surrounds the content-area and extends to the outer edge of the padding on each side.&lt;/p&gt;

&lt;h4&gt;
  
  
  border-area
&lt;/h4&gt;

&lt;p&gt;specified using &lt;code&gt;border&lt;/code&gt; or the &lt;code&gt;border-*&lt;/code&gt; sub-properties.&lt;/p&gt;

&lt;p&gt;This is the area surrounding the padding-area and extending up to the outer edge of the border on each side.&lt;/p&gt;

&lt;h4&gt;
  
  
  margin-area
&lt;/h4&gt;

&lt;p&gt;specified as &lt;code&gt;margin&lt;/code&gt; or using the &lt;code&gt;margin-*&lt;/code&gt; sub-properties.&lt;/p&gt;

&lt;p&gt;The area surrounding the border-area and extending up to the edge of the margin specified on each side.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Box
&lt;/h2&gt;

&lt;p&gt;Based on these areas and their different combinations, the browser uses different boxes when it computes the layout for a each element in the document... &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;content-box&lt;/strong&gt; - it is the innermost box (or the content-area) of the element that renders the actual content - text, images and other elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;padding-box&lt;/strong&gt; - from the outer edge of the content box and up to the outer edge of the padding-area. If padding width and height is 0, then padding-box will be same as content-box. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-box&lt;/strong&gt; - starts from the outer area of the padding-box up to the outer edge of the border-area. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;margin-box&lt;/strong&gt; - the area of the element beyond the border-box and up to the outer edge of the margin-area.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;visual-box&lt;/strong&gt; - the box that is seen on the web page, this includes the content, padding and border. The margin is not a part of this. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;layout-box&lt;/strong&gt; - the space occupied by the element on the document - including its content, padding, border and margin. This space is used for layout and position on the document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;paint-box&lt;/strong&gt; - this is the paintable area of the element. This area is the excludes the &lt;em&gt;margin-area&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;coord-box&lt;/strong&gt; - this is the location and size of the element within its parent. These coordinates exclude the margin area (of the parent).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sub-Properties
&lt;/h2&gt;

&lt;p&gt;Using sub-properties, different values can be set for the top, left, bottom and right sides of padding, border and margin.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;padding&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;padding-left&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-right&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-top&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-bottom&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-block&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-block-start&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-block-end&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-inline&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-inline-start&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding-inline-end&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;border&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;border-left-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-right-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-top-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-bottom-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-block-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-block-start-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-block-end-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-inline-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-inline-start-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border-inline-end-width&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;border property has sub-properties for setting styles and color of each side.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;margin&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;margin-left&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-right&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-top&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-bottom&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-block&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-block-start&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-block-end&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-inline&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-inline-start&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin-inline-end&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;box-sizing&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;CSS allows for two box-sizing options.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;content-box&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&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%2Fczk25abbtpmscc3fsj3s.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%2Fczk25abbtpmscc3fsj3s.png" alt="when box-sizing is content-box" width="378" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a &lt;code&gt;content-box&lt;/code&gt;, the &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;min-width&lt;/code&gt;, &lt;code&gt;max-width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, &lt;code&gt;min-height&lt;/code&gt;, &lt;code&gt;max-height&lt;/code&gt; properties denote the dimension of the content-area. The padding, border etc add on to this to compute the &lt;code&gt;&amp;lt;layout-box&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;border-box&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&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%2F9iz921xmmv1cbrtboqh8.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%2F9iz921xmmv1cbrtboqh8.png" alt="when box-sizing is border-box" width="370" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a &lt;code&gt;border-box&lt;/code&gt;, the &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;min-width&lt;/code&gt;, &lt;code&gt;max-width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, &lt;code&gt;min-height&lt;/code&gt;, &lt;code&gt;max-height&lt;/code&gt; properties set the dimensions of the &lt;code&gt;&amp;lt;paint-box&amp;gt;&lt;/code&gt;, i.e. the content, padding and border areas are include within the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>boxsizing</category>
      <category>width</category>
      <category>height</category>
      <category>layout</category>
    </item>
    <item>
      <title>Animation in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Fri, 11 Oct 2024 05:42:37 +0000</pubDate>
      <link>https://dev.to/gajendra/animation-in-css-5hn9</link>
      <guid>https://dev.to/gajendra/animation-in-css-5hn9</guid>
      <description>&lt;p&gt;Animation in CSS has two parts - &lt;code&gt;@keyframes&lt;/code&gt; and &lt;code&gt;animation-*&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;@keyframes&lt;/code&gt; at-rule
&lt;/h2&gt;

&lt;p&gt;The first part requires us to define the &lt;code&gt;@keyframes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This lets us specify the CSS-style that should apply at the different points in the duration of the animation.&lt;/p&gt;

&lt;p&gt;The different points of time are specified in % values. Any number of offsets positions between 0 and 100 percent can be specified.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from&lt;/code&gt; can be used for offset &lt;code&gt;0%&lt;/code&gt;, and &lt;code&gt;to&lt;/code&gt; is the same as the offset &lt;code&gt;100%&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;anim-name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nt"&gt;from&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;css-style-a&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;css-style-b&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below the css style has been specified for three time-points for one property - &lt;code&gt;background-color&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;colorit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;silver&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It may as well specify multiple properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;colorit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
            &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
            &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
            &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
            &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;75px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;silver&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
            &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;animation-*&lt;/code&gt; properties
&lt;/h2&gt;

&lt;p&gt;Here is a list of properties that can be used to control how the transition of styles will be done to give the UI/UX of an animation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;animation-composition&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-delay&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-direction&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-duration&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-fill-mode&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-iteration-count&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-play-state&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-range&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-range-end&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-range-start&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-timeline&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;animation-timing-function&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of this sub-property sets some aspect of the animation.&lt;/p&gt;

&lt;p&gt;Below is the definition for @keyframes named &lt;code&gt;colorit&lt;/code&gt; to be run for 3 seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
        &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;colorit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="err"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the sub-properties can be specified in a single line using the &lt;code&gt;animation&lt;/code&gt; shorthand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;3&lt;/span&gt;&lt;span class="nt"&gt;s&lt;/span&gt; &lt;span class="nt"&gt;colorit&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser does the math required and renders the appropriate animation. &lt;/p&gt;

&lt;p&gt;Similarly, the animation properties allow the control of delay, timing, number of times (iteration), direction etc. for the designer to achieve his vision.&lt;/p&gt;

</description>
      <category>animation</category>
      <category>keyframes</category>
      <category>css</category>
      <category>webdesign</category>
    </item>
    <item>
      <title>Variables in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Wed, 02 Oct 2024 10:40:28 +0000</pubDate>
      <link>https://dev.to/gajendra/variables-custom-properties-in-css-3eko</link>
      <guid>https://dev.to/gajendra/variables-custom-properties-in-css-3eko</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;CSS variables allow us to store a value to some identifier and then use that identifier wherever and whenever that value is needed.&lt;/p&gt;

&lt;p&gt;In CSS a variable is an identifier preceeded with two dashes (&lt;code&gt;--&lt;/code&gt;). To use variables, just..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define @property&lt;/li&gt;
&lt;li&gt;Assign values&lt;/li&gt;
&lt;li&gt;Use the value var() function

&lt;ul&gt;
&lt;li&gt; Fallback values&lt;/li&gt;
&lt;li&gt; Invalid values&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Personally, I feel variables are the coolest addition to the CSS stable. &lt;/p&gt;

&lt;p&gt;It has made the task of maintaining and fine-tuning my UI/UX so much easier. I do not have to find and replace every usage of a color value.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Use @property
&lt;/h2&gt;

&lt;p&gt;The use of this at-rule is optional. The code works fine even if &lt;code&gt;@property&lt;/code&gt; definition is not provided.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@property&lt;/span&gt; &lt;span class="n"&gt;--my-forecolor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="py"&gt;syntax&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="py"&gt;inherits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="py"&gt;initial-value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;darkblue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;@property&lt;/code&gt; lets you define the type of the variable, a default value and it allows you to control its inheritance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assign values
&lt;/h2&gt;

&lt;p&gt;Specify two dashes (&lt;code&gt;--&lt;/code&gt;) followed by a name for the custom property and assign a valid CSS value after a colon (&lt;code&gt;:&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--my-forecolor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.classname&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--my-forecolor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A custom property assigned without the &lt;code&gt;@property&lt;/code&gt; at-rule is always inherited.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scope of the Variable
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Global
&lt;/h4&gt;

&lt;p&gt;A variable declared in the &lt;code&gt;:root&lt;/code&gt; selector has the &lt;strong&gt;global scope&lt;/strong&gt; and can be used throughout the entire document.&lt;/p&gt;

&lt;h4&gt;
  
  
  Local
&lt;/h4&gt;

&lt;p&gt;It has a &lt;strong&gt;local scope&lt;/strong&gt; if the variable is declared inside the selector where you want to use it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the code above globally the value of &lt;code&gt;--my-forecolor&lt;/code&gt; is red, but in the elements having class as &lt;code&gt;.classname&lt;/code&gt; its value will be blue.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  var() Function
&lt;/h2&gt;

&lt;p&gt;The value in the custom variable can be referenced with the &lt;code&gt;var()&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.heading&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--my-forecolor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Fallback values
&lt;/h3&gt;

&lt;p&gt;You can add a fallback value to the var() function.&lt;/p&gt;

&lt;p&gt;The second argument in the var() function is the optional fallback value, which is used when the reference value of the variable is &lt;em&gt;invalid&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;var&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;--my-own-color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;blue&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fallback value here is &lt;em&gt;blue&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The second argument could also reference a variable, like this...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;var&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;--my-own-color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;var&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;--my-forecolor&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and, the second variable could also have a fallback...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;var&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;--my-own-color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;var&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;--my-forecolor&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;maroon&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Invalid Custom Properties
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Without variables&lt;/strong&gt; - When the value assigned to any property is invalid, that declaration is ignored and style is computed as if that declaration did not exist.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight css"&gt;&lt;code&gt;   &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;lightcyan&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30deg&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;pre class="highlight html"&gt;&lt;code&gt;   &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;This line is printed&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;Here the output would have the color blue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With variables&lt;/strong&gt; - &lt;/p&gt;

&lt;p&gt;If the value of the variable being referenced is invalid for that property then the &lt;code&gt;inital&lt;/code&gt; or &lt;code&gt;inherit&lt;/code&gt;ed value is used.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="py"&gt;--cust-var&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;lightpink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--cust-var&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;pre class="highlight html"&gt;&lt;code&gt;   &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;This line is printed&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;50px may be a valid value for length but for color it is invalid, so here the output would be printed in &lt;code&gt;black&lt;/code&gt; - the browser's initial value.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;@property&lt;/code&gt; at-rule is added, and the value of the variable is invalid, then the &lt;code&gt;initial-value&lt;/code&gt; of the property will be used.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@property&lt;/span&gt; &lt;span class="n"&gt;--cust-var&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="py"&gt;syntax&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'&amp;lt;color&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="py"&gt;inherits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="py"&gt;initial-value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="py"&gt;--cust-var&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;lightyellow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--cust-var&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;Here the output would be printed in &lt;code&gt;red&lt;/code&gt; - the initial value defined the property at-rule.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Units for Values in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Mon, 30 Sep 2024 05:19:06 +0000</pubDate>
      <link>https://dev.to/gajendra/units-for-values-in-css-1eh3</link>
      <guid>https://dev.to/gajendra/units-for-values-in-css-1eh3</guid>
      <description>&lt;h1&gt;
  
  
  Units in CSS
&lt;/h1&gt;

&lt;p&gt;Values are regularly used in CSS. These are specified sometimes in absolute units and at other times in relative units.&lt;/p&gt;

&lt;p&gt;CSS provides units for length, angle, frequency and within each category it supports conversion between the different units of measurement.&lt;/p&gt;

&lt;p&gt;It is good to have an understanding of the various units or measurement that CSS supports. This allows web developers and designers to work within their comfortable zones.&lt;/p&gt;

&lt;p&gt;Below is a list of units supported in CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Absolute Units
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Length
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cm&lt;/code&gt;, &lt;code&gt;mm&lt;/code&gt;, &lt;code&gt;Q&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt;, &lt;code&gt;pt&lt;/code&gt;, &lt;code&gt;pc&lt;/code&gt;, &lt;code&gt;px&lt;/code&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Equivalent to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;cm&lt;/td&gt;
&lt;td&gt;Centimeters&lt;/td&gt;
&lt;td&gt;1cm = 37.8px = 1/2.54 of 1in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mm&lt;/td&gt;
&lt;td&gt;Millimeters&lt;/td&gt;
&lt;td&gt;1mm = 1/10 of 1cm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Q&lt;/td&gt;
&lt;td&gt;Quarter-millimeters&lt;/td&gt;
&lt;td&gt;1Q = 1/40 of 1cm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;in&lt;/td&gt;
&lt;td&gt;Inches&lt;/td&gt;
&lt;td&gt;1in = 2.54cm = 96px&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pc&lt;/td&gt;
&lt;td&gt;Picas&lt;/td&gt;
&lt;td&gt;1pc = 1/6 of 1in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pt&lt;/td&gt;
&lt;td&gt;Points&lt;/td&gt;
&lt;td&gt;1pt = 1/72 of 1in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;px&lt;/td&gt;
&lt;td&gt;Pixels&lt;/td&gt;
&lt;td&gt;1px = 1/96 of 1in&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Angles
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;deg&lt;/code&gt;, &lt;code&gt;grad&lt;/code&gt;, &lt;code&gt;rad&lt;/code&gt;, &lt;code&gt;turn&lt;/code&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Equivalent to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;deg&lt;/td&gt;
&lt;td&gt;Degree&lt;/td&gt;
&lt;td&gt;360deg = 1 full circle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;grad&lt;/td&gt;
&lt;td&gt;Gradian&lt;/td&gt;
&lt;td&gt;400grad = 1 full circle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;rad&lt;/td&gt;
&lt;td&gt;Radian&lt;/td&gt;
&lt;td&gt;6.2832rad = 1 full circle &lt;br&gt; (π approx = 3.1416)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;turn&lt;/td&gt;
&lt;td&gt;Turn&lt;/td&gt;
&lt;td&gt;1 turn = 1 full cirle&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Time
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;s&lt;/code&gt;, &lt;code&gt;ms&lt;/code&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;unit&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;equivalent to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;s&lt;/td&gt;
&lt;td&gt;second&lt;/td&gt;
&lt;td&gt;1s = 1000ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ms&lt;/td&gt;
&lt;td&gt;millisecond&lt;/td&gt;
&lt;td&gt;1ms = 1/1000 of 1s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Frequency Units
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Hz&lt;/code&gt;, &lt;code&gt;kHz&lt;/code&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;unit&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;equivalent to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hz&lt;/td&gt;
&lt;td&gt;Hertz&lt;/td&gt;
&lt;td&gt;1Hz = 1/1000 of 1 kHz&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kHz&lt;/td&gt;
&lt;td&gt;Kilo Hertz&lt;/td&gt;
&lt;td&gt;1KHz = 1000Hz&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Resolution Units
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;dpi&lt;/code&gt;, &lt;code&gt;dpcm&lt;/code&gt;, &lt;code&gt;dppx&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Relative Units
&lt;/h2&gt;

&lt;p&gt;As the name suggests, these values provided with these units are relative to some other value. It could be related to some parent element or the viewport.&lt;/p&gt;

&lt;h3&gt;
  
  
  Font Related
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;em&lt;/code&gt;, &lt;code&gt;ex&lt;/code&gt;, &lt;code&gt;ch&lt;/code&gt;, &lt;code&gt;rem&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Viewport Related
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;%&lt;/code&gt;, &lt;code&gt;vw&lt;/code&gt;, &lt;code&gt;vh&lt;/code&gt;, &lt;code&gt;vmin&lt;/code&gt;, &lt;code&gt;vmax&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Container Query Related
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cqw&lt;/code&gt;, &lt;code&gt;cqh&lt;/code&gt;, &lt;code&gt;cqi&lt;/code&gt;, &lt;code&gt;cqb&lt;/code&gt;, &lt;code&gt;cqmin&lt;/code&gt;, &lt;code&gt;cqmax&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is common practice to define an absolute value to the container element and then use relative values for all descendant elements.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>css</category>
      <category>units</category>
      <category>relative</category>
      <category>absolute</category>
    </item>
    <item>
      <title>Container Queries in CSS</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Sat, 28 Sep 2024 07:20:46 +0000</pubDate>
      <link>https://dev.to/gajendra/container-queries-in-css-3o6a</link>
      <guid>https://dev.to/gajendra/container-queries-in-css-3o6a</guid>
      <description>&lt;p&gt;First a container must be registered, and it can be queried. &lt;/p&gt;

&lt;h2&gt;
  
  
  Register a Container
&lt;/h2&gt;

&lt;p&gt;Use a selector to register a &lt;code&gt;container&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;container-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;container-type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;other&lt;/span&gt; &lt;span class="err"&gt;code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or, use the shorthand option&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.parent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="n"&gt;inline-size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="err"&gt;other&lt;/span&gt; &lt;span class="err"&gt;code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the time of registration, two details - &lt;code&gt;type&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt; - have to specified.&lt;/p&gt;

&lt;h3&gt;
  
  
  Container Type
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;container-type: ...&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;inline-size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;normal&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Container Name
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;container-name: &amp;lt;nameofcontainer&amp;gt;;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;nameofcontainer&amp;gt;&lt;/code&gt; identifies the container especially useful if you may a scenario of multiple containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Query a Container
&lt;/h2&gt;

&lt;p&gt;The container query starts with the &lt;code&gt;@container&lt;/code&gt; at-rule followed by the name of the container and the feature query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;30ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;container query to set &lt;code&gt;font-size&lt;/code&gt; for the &lt;code&gt;div&lt;/code&gt; inside the &lt;code&gt;myname&lt;/code&gt; container to &lt;code&gt;3em&lt;/code&gt; if the feature &lt;code&gt;width&lt;/code&gt; is greater than &lt;code&gt;30ch&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features to Query
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;size-query...&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;height&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;inline-size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;block-size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;aspect-ratio&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;orientation&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;style-query...&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;style(property: value)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;property&lt;/code&gt; to be checked for &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;for eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;contname&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;'background-color: blue'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt; 
    &lt;span class="nt"&gt;styles&lt;/span&gt; 
    &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container query to apply styles if the &lt;code&gt;background-color&lt;/code&gt; of the container &lt;code&gt;contname&lt;/code&gt; is blue &lt;/p&gt;

&lt;h3&gt;
  
  
  Compound Queries
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt; and &lt;code&gt;not&lt;/code&gt; can be used to create compound queries&lt;/p&gt;

&lt;p&gt;for eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="m"&gt;30ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="n"&gt;not&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nested Container Queries
&lt;/h3&gt;

&lt;p&gt;Container queries can be nested within other container queries.&lt;/p&gt;

&lt;p&gt;for eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="m"&gt;30ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;...&lt;/span&gt;
        &lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="o"&gt;...&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;@container&lt;/span&gt; &lt;span class="n"&gt;myname&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="o"&gt;...&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>css</category>
      <category>container</category>
      <category>size</category>
      <category>style</category>
    </item>
    <item>
      <title>CSS: List of Properties for Text</title>
      <dc:creator>Gajendra Dhir</dc:creator>
      <pubDate>Thu, 26 Sep 2024 10:15:48 +0000</pubDate>
      <link>https://dev.to/gajendra/css-list-of-properties-for-text-a1m</link>
      <guid>https://dev.to/gajendra/css-list-of-properties-for-text-a1m</guid>
      <description>&lt;p&gt;This is cheat-sheet list of properties that decide how text is displayed. fonts, styles, alignment, spacing etc. &lt;/p&gt;

&lt;h2&gt;
  
  
  Fonts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;font-family&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-size-adust&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-style&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-variant&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-variant-caps&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-weight&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@font-face&lt;/code&gt; (at-rule)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Text
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;text-align&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-align-last&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-decoration&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-decoration-color&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-decoration-line&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-decoration-style&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-decoration-thickness&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-emphasis&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-emphasis-color&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-emphasis-position&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-emphasis-style&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-indent&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-justify&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-orientation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-overflow&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-shadow&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-transform&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-underline-offset&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;text-underline-position&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Others
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;hanging-punctuation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hyphenate-limit-chars&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hyphens&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;letter-spacing&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;line-height&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;orphans&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;overflow-wrap&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tab-size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;white-space&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;white-space-collapse&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;widows&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;word-break&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;word-spacing&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;word-wrap&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;writing-mode&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>cheatsheet</category>
      <category>fonts</category>
      <category>text</category>
    </item>
  </channel>
</rss>
