<?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: ayush-tha</title>
    <description>The latest articles on DEV Community by ayush-tha (@ayushtha).</description>
    <link>https://dev.to/ayushtha</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%2F1066934%2Fb818e964-372e-4388-aa89-03ada6a7ff26.jpeg</url>
      <title>DEV Community: ayush-tha</title>
      <link>https://dev.to/ayushtha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayushtha"/>
    <language>en</language>
    <item>
      <title>CSS Display Property: Exploring Different Values And Their Effects</title>
      <dc:creator>ayush-tha</dc:creator>
      <pubDate>Fri, 21 Apr 2023 08:51:38 +0000</pubDate>
      <link>https://dev.to/ayushtha/css-display-property-exploring-different-values-and-their-effects-58l</link>
      <guid>https://dev.to/ayushtha/css-display-property-exploring-different-values-and-their-effects-58l</guid>
      <description>&lt;p&gt;When building a website or web product, the most crucial factor to consider is user experience. A good user experience makes all the difference; therefore, it should be prioritized. When a user lands on a web page, the first thing their eyes are drawn to is the overall display of the site. This visual design is integral to the overall experience and can make or break how a visitor feels about your site.&lt;/p&gt;

&lt;p&gt;Each element of the web page should be at its best display behavior to give an eye-comforting experience to the site’s visitors. To manipulate the display behavior of each element, you can use CSS Display Property, a powerful helping hand tool. CSS styling comes with a &lt;em&gt;display property&lt;/em&gt; that lets you experiment with the display behavior of the different elements on a web page and achieve the best user experience.&lt;/p&gt;

&lt;p&gt;Not just display when it comes to user experience, the website’s layout also plays a vital role. But in major cases, the actual implementation and layout creation is much more complicated than designing its wireframe. However, CSS has numerous properties to initialize the different aspects of different items present in the layout, such as size, position, location, padding, etc. But still, it becomes a very struggling task to create a perfect layout by using those traditional CSS properties.&lt;/p&gt;

&lt;p&gt;And this is where CSS Display Property saves us from spending too much time designing layouts. CSS Display Property also allows us to configure the whole layout of the site by converting the layout into a &lt;a href="https://www.lambdatest.com/blog/css-flexbox-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;Flexbox&lt;/a&gt; or Grid model layout. Furthermore, we can take advantage of the properties that define model layout features and implement the whole layout much more quickly.&lt;/p&gt;

&lt;p&gt;As explained earlier, the CSS Display property allows us to assign the display behavior of the whole interface of the web page and the elements present inside it.&lt;/p&gt;

&lt;p&gt;CSS Display Property has many predefined keyword attributes that can be leveraged to get the desired results. Let’s dive deep into each of these in the coming sections of this blog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This smoke testing tutorial covers what&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/smoke-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;smoke testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  display: block
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “block” value is commonly used to create page layouts with elements taking up the full width of their container. The &lt;em&gt;block&lt;/em&gt; attribute creates a whole new block and shows the assigned element in that block. Since a new block is created, the element starts from a new line instead of continuing with the last element.&lt;/p&gt;

&lt;p&gt;By default, the newly created block takes up the whole available space, but thanks to CSS Display Property, i.e., CSS styling that helps you change the width and height of the block.&lt;/p&gt;

&lt;p&gt;Some elements have the display behavior as a block by default. These elements will always have a block as their display behavior with or without assigning any specific display behavior to them. These special elements include &lt;code&gt;&amp;lt; div &amp;gt;, &amp;lt; p &amp;gt;, and &amp;lt; section &amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;Text for Example, &amp;lt;span&amp;gt;Text for Example&amp;lt;/span&amp;gt; Text for Example&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  font-weight: bold;
  font-size: x-large;
}
span {
  display: block;
  background-color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UEm1SAeb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AEksgBQkegE0RSGCn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UEm1SAeb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AEksgBQkegE0RSGCn.png" alt="image" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can observe that for the &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; tag, we have used the CSS Display Property and assigned it to the block attribute. This has made the &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; appear in a new &lt;em&gt;block&lt;/em&gt; taking up the whole screen width.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;display: block&lt;/strong&gt;, the CSS Display Property is essential for creating page layouts where elements take up the full width of their parent container.&lt;/p&gt;

&lt;h3&gt;
  
  
  display: inline
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “inline” value is often used for inline elements, such as links or text, to appear side-by-side horizontally. The &lt;em&gt;inline&lt;/em&gt; attribute also creates a new &lt;em&gt;block&lt;/em&gt;, just like the block attribute. Still, instead of displaying in a new line, the element with the &lt;em&gt;inline&lt;/em&gt; attribute stays in continuity with the previous element. The space occupied by the inline attribute is just as same as a common element would occupy.&lt;/p&gt;

&lt;p&gt;Since it does not take up the whole screen space, it restricts us from manipulating the height and width of the element.&lt;/p&gt;

&lt;p&gt;Like the &lt;em&gt;block&lt;/em&gt; attribute, the inline attribute has some specific elements that display inline behavior by default. These specific elements include &lt;code&gt;&amp;lt; span &amp;gt;, &amp;lt; a &amp;gt;, &amp;lt; i &amp;gt;, and &amp;lt; img &amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;span {
  display: inline;
  background-color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oYxgfPS2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A8dxUTxvQKe6ixGrc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oYxgfPS2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A8dxUTxvQKe6ixGrc.png" alt="image" width="690" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the previous HTML code, we have embedded the CSS Display Property in &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; tag and assigned it to the &lt;em&gt;inline&lt;/em&gt; attribute. This has created a separate block for the &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; tag and displays it in continuity with the previous elements.&lt;/p&gt;

&lt;p&gt;When using &lt;strong&gt;display: inline&lt;/strong&gt;, the CSS Display Property is used to position elements side-by-side horizontally, making it a good value for creating menus or lists.&lt;/p&gt;

&lt;h3&gt;
  
  
  display: inline-block
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “inline-block” value is useful for creating custom form elements, such as checkboxes or radio buttons, that can be horizontally and vertically aligned.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;inline-block&lt;/em&gt; attribute works exactly similarly to the &lt;em&gt;inline&lt;/em&gt; attribute. However, the major difference between the inline attribute and the inline-block attribute is that, unlike the inline attribute, the block created by the inline-block allows us to manipulate its height and width depending on the requirements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;span {
  display: inline-block;
  width: 100px;
  background-color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DxQvrQGS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AexZfx5tGYTe9WKUN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DxQvrQGS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AexZfx5tGYTe9WKUN.png" alt="image" width="600" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, for the &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; tag, we have used the CSS Display property and added the &lt;em&gt;inline-block&lt;/em&gt; property. After that, we changed the block’s width created by the inline-block attribute. You can notice the significant changes in this example and the previous one.&lt;/p&gt;

&lt;p&gt;Using the &lt;strong&gt;display: inline-block&lt;/strong&gt; value with CSS Display Property allows for custom form elements to be aligned horizontally and vertically, giving web developers more flexibility when designing &lt;a href="https://www.lambdatest.com/blog/css-forms/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS styling forms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A complete&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;Manual testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial covering all aspects of Manual testing, including strategies and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  display: inherit
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “inherit” value is used to make an element inherit its parent’s display property value. The inherit attribute is the only attribute offered by CSS Display Property. As the name suggests, the inherit attribute simply makes an element inherit or grab the CSS display property of its parent element.&lt;/p&gt;

&lt;p&gt;In other words, whatever the display behavior an element will have, its child element will have the same behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;span&amp;gt;Text for Example |
      &amp;lt;div&amp;gt;Text for Example |&amp;lt;/div&amp;gt;
      Text for Example&amp;lt;/span&amp;gt;
  &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  font-weight: bold;
  font-size: x-large;
}
div {
  display: inherit;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cynVpwBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AeOmOzDRyoMWYeWON.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cynVpwBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AeOmOzDRyoMWYeWON.png" alt="image" width="728" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we have used a &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; element and inside of that we have initialised a &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; element. As per the default display behavior of &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; tag, all three statements should appear in 3 separate lines. Since we have initialized CSS Display Property for the styling of &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; tag and attached it to the inherit attribute. The &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; tag has inherited the CSS Display Property of tag, i.e., inline-block. Therefore, we are getting all three statements in a single line.&lt;/p&gt;

&lt;p&gt;By setting &lt;strong&gt;display: inherit&lt;/strong&gt; with the CSS Display Property, web developers can ensure that an element inherits its parent container’s CSS display property value, simplifying styling and promoting consistency across a page.&lt;/p&gt;

&lt;h3&gt;
  
  
  display: initial
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “initial” value is used to reset an element’s display property value to its default value. The &lt;em&gt;initial&lt;/em&gt; attribute simply sets the element to its default display behavior. So, if we assign a CSS display property to the initial attribute in a &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; tag, the display behavior will be set to its default value, i.e., inline-block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div&amp;gt;
      Text for Example |
      &amp;lt;span&amp;gt;Text for Example |&amp;lt;/span&amp;gt;
      Text for Example
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  font-weight: bold;
  font-size: x-large;
}
span {
  display: initial;
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we have assigned the CSS Display Property to the &lt;em&gt;initial&lt;/em&gt; attribute for the &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; tag. Therefore, all three statements are displayed as an inline block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0r0c9xOI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AtwIv-3sV7LYaX26P.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0r0c9xOI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AtwIv-3sV7LYaX26P.png" alt="image" width="724" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CSS Display Property’s initial value, &lt;strong&gt;display: initial&lt;/strong&gt;, helps reset an element’s display property value to its default value, which can be especially helpful when starting a new project.&lt;/p&gt;

&lt;h3&gt;
  
  
  display: none
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “none” value is often used to hide elements from the page without deleting them from the HTML code. The none attribute of the &lt;em&gt;display&lt;/em&gt; attribute just makes the entire element content invisible. This attribute makes the whole element withdrawn from the page by leaving no mark behind. It will be like that element never existed on the layout.&lt;/p&gt;

&lt;p&gt;If you think removing an aspect will affect the whole layout, then no, this attribute does not affect the layout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  font-weight: bold;
  font-size: x-large;
}
span {
  display: none;
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yG6C1va6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A0L8Vcgwo_CPuUaG9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yG6C1va6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A0L8Vcgwo_CPuUaG9.png" alt="image" width="485" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the CSS Display property has been assigned to none attribute for the &lt;code&gt;&amp;lt; span &amp;gt;&lt;/code&gt; element. Therefore, it’s taken off from the layout.&lt;/p&gt;

&lt;p&gt;In other words, the CSS Display Property’s none value, &lt;strong&gt;display: none&lt;/strong&gt;, is commonly used to hide elements from a page without deleting them from the HTML code, making it useful for toggling content visibility in response to user interactions.&lt;/p&gt;

&lt;h3&gt;
  
  
  display: flex
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “flex” value is commonly used for creating responsive layouts, allowing elements to adjust their size and position based on the available space. We have been discussing some basic attributes of the CSS &lt;em&gt;display&lt;/em&gt; property. But now it’s time for two major attributes — Flex and Grid. First, let’s discuss the flex attribute, and then we will hop into the &lt;em&gt;grid&lt;/em&gt; attribute.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;flex&lt;/em&gt; attribute converts the whole display behavior of the element into the flex layout. Flex layout (popular by the name Flexbox layout) is a pre-designed layout model which helps us to create the whole layout. Flexbox layouts have several properties that allow us to align the child elements into the desired positions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div class="flex-container"&amp;gt;
      &amp;lt;div class="flex-item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="flex-item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="flex-item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="flex-item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="flex-item"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flex-container {
  display: flex;
  border: 2px solid black;
}


.flex-item {
  height: 100px;
  width: 100px;
  border: 1px solid black;
  background-color: #cff5e7;
  margin: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1EzEbPge--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A9Bn4sKX-Je3qXTjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1EzEbPge--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A9Bn4sKX-Je3qXTjd.png" alt="image" width="800" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, there’s a main container &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; tag, and in that, 5 &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; tags are working as a child element to it. You can observe that we have initialized the CSS Display Property and assigned it to the flex attribute for the container &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt; element. This has created the flexbox layout in the container element, and each child element is aligned horizontally.&lt;/p&gt;

&lt;p&gt;Since the default behavior of flexbox layout is to align horizontally (row-wise), we are getting such results. However, the Flexbox allows us to change the alignment using the &lt;em&gt;flex-direction&lt;/em&gt; property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; flex-direction: column;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VTBTbXu1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aml4N9nP8P6WNk1Yq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VTBTbXu1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aml4N9nP8P6WNk1Yq.png" alt="image" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above figure, you can observe that on applying the column attribute to the &lt;em&gt;flex-direction&lt;/em&gt; property, all the child items get aligned in the vertical direction (column-wise). That’s how &lt;em&gt;flex-direction&lt;/em&gt; property helps us to align child items.&lt;/p&gt;

&lt;p&gt;There are a bunch of other alignment properties that flexbox layout comes with. Since many of the alignment properties of flexbox layout are the same as of &lt;em&gt;grid&lt;/em&gt; attribute offers. Hence, first, lets us have some knowledge of grid attribute and then understand the alignment properties.&lt;/p&gt;

&lt;p&gt;When using &lt;strong&gt;display: flex&lt;/strong&gt;, the CSS Display Property provides a powerful tool for creating responsive layouts that can adjust their size and position based on the available space, making it a popular choice for &lt;a href="https://www.lambdatest.com/blog/20-elements-of-modern-web-design/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;modern web design&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A complete&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;Manual testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial covering all aspects of Manual testing, including strategies and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  display: grid
&lt;/h3&gt;

&lt;p&gt;The CSS Display Property with the “grid” value is used for creating complex layouts by defining rows and columns and placing elements within them. In CSS, assigning positions to the elements to get the desired results has always been hectic and stressful.&lt;/p&gt;

&lt;p&gt;Almost every CSS developer would have faced a situation where he is given some position to an element, and the other elements besides it get disoriented. One of the best solutions to avoid this type of situation is to use the CSS Grid Layout Module.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/css-grid/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS Grid&lt;/a&gt; is a &lt;em&gt;2-dimensional grid layout system&lt;/em&gt; comprising a defined number of rows and columns. At the intersection points of rows and columns, blocks (empty cells) get formed. These blocks work as a container where we can add the elements we want to display on the web page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WxjBaNVi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AhB7fIpi9eymuBbhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WxjBaNVi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AhB7fIpi9eymuBbhz.png" alt="image" width="724" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above figure, we have attempted to showcase a CSS Grid (looking very much like a table filled with blue color). On the vertical track, we have columns; on the horizontal track, we have rows. So, in the above representation, we have three columns with four rows.&lt;/p&gt;

&lt;p&gt;The intersection of these rows and columns gives rise to Grid cells, which work as a container where we can insert the layout elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GTpzPRdg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AJjBXMlv0jOCXdatH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GTpzPRdg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AJjBXMlv0jOCXdatH.png" alt="image" width="627" height="563"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we can observe that a combination of 4 rows and 3 columns gives us 12 (4 x 3) cells, also called Grid cells. There’s one more important terminology related to CSS Grid: Grid Item. Grid Item is the direct children of any particular cell or container; those children could be any kind of tag containing any data.&lt;/p&gt;

&lt;p&gt;For better understanding, you can take the example of Microsoft Excel. A CSS Grid Layout has striking similarities with Microsoft Excel Sheet. An excel sheet consists of rows and columns just like a CSS Grid, and in an Excel sheet, we add the data and perform mathematical formulations inside the cells, which is again exactly like the CSS Grid.&lt;/p&gt;

&lt;p&gt;Now we have gained good enough information about the CSS Grid, let’s deep dive to see where CSS Grid can be used in practical applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to use CSS Grid?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To apply the functionality of CSS Grid layout in the basic layout, we simply have to assign the CSS display property to the grid attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;display: grid;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding just this simple line makes the whole layout behave as a grid layout. If you want, you can convert the whole screen layout into a CSS Grid layout, or any particular div tag could be converted to a CSS Grid layout depending upon your requirements.&lt;/p&gt;

&lt;p&gt;CSS Grid layout demands assigning the number of rows and columns we want in the grid to form the cells. To add the rows and columns in the grid, CSS grid comes with two properties, namely grid-template-rows property to add rows and grid-template-columns property to add columns. Let’s see some examples of it.&lt;/p&gt;

&lt;p&gt;Check out the best &lt;a href="https://www.lambdatest.com/blog/best-css-grid-layout-generators/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS Grid Layout Generators&lt;/a&gt; that help you in fast prototyping and front-end design of CSS layouts for your projects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  height: 500px;
  width: 550px;
  border: 2px solid black;
  display: grid;
  grid-template-rows: 133px 133px 133px;
  grid-template-columns: 133px 133px 133px;
}


.item {
  height: 100px;
  width: 100px;
  border: 2px solid black;
  margin-top: 10px;
  margin-left: 10px;
  background-color: aqua;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w1mpjJwL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AA-R5_sUJazPnOoCE.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w1mpjJwL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AA-R5_sUJazPnOoCE.png" alt="image" width="706" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we have created a &lt;em&gt;container div&lt;/em&gt; tag and multiple &lt;em&gt;item div&lt;/em&gt; tags. Then, some basic CSS styling was assigned to it. Afterward, we converted the &lt;em&gt;container div&lt;/em&gt; layout to a grid layout by assigning CSS &lt;em&gt;display property&lt;/em&gt; to the grid attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 grid-template-rows: 133px 133px 133px;
 grid-template-columns: 133px 133px 133px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Furthermore, with the help of the &lt;em&gt;grid-template-rows&lt;/em&gt; property and &lt;em&gt;grid-template-columns&lt;/em&gt; property, we have initialized three rows and three columns to form the grid. Here you’ll notice that instead of assigning some rows and columns, we have assigned some pixel quantities to the properties.&lt;/p&gt;

&lt;p&gt;These pixel quantities are the width of the rows and columns we want, and the number of pixel quantities we have assigned is the number of rows and columns we want. So, here you can observe three-pixel quantities of 133px each. This eventually creates 3 columns and 3 rows of width 133px. Hence, the total number of cells we get in this grid is 9 (3 x 3).&lt;/p&gt;

&lt;p&gt;Let’s see some more examples of it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  height: 500px;
  width: 550px;
  border: 2px solid black;
  display: grid;
  grid-template-rows: 133px 133px 133px;
  grid-template-columns: 133px 133px 133px 133px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rRNe4Xiv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A5FUiVsZzHdUmbtoU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rRNe4Xiv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A5FUiVsZzHdUmbtoU.png" alt="image" width="704" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we have created 3 rows and 4 columns. For that, 3-pixel quantities have been assigned in the &lt;em&gt;grid-template-rows&lt;/em&gt; property, and 4-pixel quantities have been assigned in the &lt;em&gt;grid-template-columns&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;Here’s another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  grid-template-rows: 133px 133px;
  grid-template-columns: 133px 133px 133px 133px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--52Qx2O8f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ApKjLzdGhVYmwYq0b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--52Qx2O8f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ApKjLzdGhVYmwYq0b.png" alt="image" width="706" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, we have created a grid consisting of 2 rows and 4 columns. To make this grid, just like we did in the previous examples, we allocated 2-pixel quantities in the &lt;em&gt;grid-template-rows&lt;/em&gt; property and 4-pixel quantities in the &lt;em&gt;grid-template-columns&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A complete tutorial on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/retesting?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;retesting&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that sheds light on its features, importance, pros and cons, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have been using pixel quantities to define the width and number of rows and columns. However, on a professional level, the use of fraction (fr) units is more favorable to a great extent than the use of pixel units in the case of CSS Grids. The &lt;em&gt;fr&lt;/em&gt; unit signifies the fraction of the available space inside a container or block. Let’s understand the use of fr unit in CSS Grid.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  grid-template-rows: 1fr 1fr;
  grid-template-columns: 1fr 1fr; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, in this example, you can observe that in the &lt;em&gt;grid-template-rows&lt;/em&gt; property and &lt;em&gt;grid-template-columns&lt;/em&gt; property we have made the use of fr units. We have assigned 2 fr units of quantity one, which ultimately created the two fractions of the whole space available in the container, and both fractions are of the same width.&lt;/p&gt;

&lt;p&gt;We have used the same 2 fr units of 1 quantity in both the grid-template-rows property and &lt;em&gt;grid-template-columns&lt;/em&gt; property, resulting in 2 rows and 2 columns, respectively. All this results in the generation of 4 cells (2 x 2) that you can observe in the example.&lt;/p&gt;

&lt;p&gt;Fr units come in super handy when we have to divide a particular container into any number of equal parts, but the container’s space is unknown to us. To simplify it, you can use the repeat function of CSS and assign it the fraction unit and the number of times you want to repeat it (as shown below snippet).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  grid-template-rows: repeat(2, 1fr);
  grid-template-columns: repeat(2, 1fr);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Till now, we were taking the example of items (present inside cells) of defined height and width, but what if we do not assign any height and width to it? In that case, the item content will expand to the whole space inside the cell.&lt;/p&gt;

&lt;p&gt;But a situation arises in this case. However, each cell item clearly distinguishes an item from its adjacent item because of its black border. But what if the &lt;a href="https://www.lambdatest.com/blog/css-borders/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS borders&lt;/a&gt; are hidden from us? How will we distinguish between the cells? column-gap and row-gap properties of CSS Grid are the answer to this situation.&lt;/p&gt;

&lt;p&gt;As the name suggests, the column-gap and row-gap properties add some gap or space between the columns and rows, respectively. This makes it visible where one row and column end and from where the next row and column begin.&lt;/p&gt;

&lt;p&gt;Until now, as you have seen, CSS Grid comprises cells formed by rows and columns, and each cell will have its item, which is restricted to that specific cell. But in a real-life situation, this is not true every time. You will find many situations where you have to expand an item from its cell to another cell to get the desired results.&lt;/p&gt;

&lt;p&gt;CSS Grid offers some Start and End properties for this type of situation. To expand the item column-wise, &lt;em&gt;grid-column-start&lt;/em&gt; and &lt;em&gt;grid-column-end&lt;/em&gt; properties are there; in the case of row-wise, we have &lt;em&gt;grid-row-start&lt;/em&gt; and &lt;em&gt;grid-row-end properties&lt;/em&gt;. What these properties do is dilate an item from one cell to another cell.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;grid-column-start&lt;/em&gt; property is used to allocate from which column the item will start, and the ending column for the item is allocated in the &lt;em&gt;grid-column-end&lt;/em&gt; property. The working of the &lt;em&gt;grid-row-start&lt;/em&gt; and &lt;em&gt;grid-row-end&lt;/em&gt; properties is exactly similar to the &lt;em&gt;grid-column properties&lt;/em&gt; for the &lt;em&gt;row-wise&lt;/em&gt;. Let’s understand their work with some examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item item1"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
     &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
     &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
     &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
     &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
     &amp;lt;div class="item"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  height: 250px;
  width: 550px;
  border: 2px solid black;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
}


.item {
  border: 1px solid black;
  margin: 10px;
  background-color: aqua;
}


.item1 {
  grid-row-start: 1;
  grid-row-end: 3;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tNWD-TaY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AIVlNmHHF1SuPaiQT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tNWD-TaY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AIVlNmHHF1SuPaiQT.png" alt="image" width="704" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, you will observe that the item of 1st cell is expanding vertically that means it’s going from start of 1st row to the beginning of 3rd row. To get this type of output, we used the &lt;em&gt;grid-row-start&lt;/em&gt; and &lt;em&gt;grid-row-end&lt;/em&gt; properties for the 1st item and assigned them to 1 and 3. This resulted in the 1st item getting enlarged from 1st row to 3rd row.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/selenium-grid-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;Selenium Grid&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to run your browser automation testing scripts on cloud infrastructure containing 3000+ desktop and mobile browser environments. Perform Selenium Testing on a cloud automation testing grid that scales along with your tests.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the same way, you can use &lt;em&gt;grid-column-start&lt;/em&gt; and &lt;em&gt;grid-column-end&lt;/em&gt; properties to enlarge the item to the desired columns. Let’s see how it works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  height: 250px;
  width: 550px;
  border: 2px solid black;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
}

.item {
  margin: 10px;
  background-color: aqua;
  border: 1px solid black;
}

.item1 {
  grid-column-start: 1;
  grid-column-end: 3;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, you can observe that the item of 1st cell is getting expanded from the start of the 1st column to the beginning of the 3rd column. To get this result, we just added the two properties, &lt;em&gt;grid-column-start&lt;/em&gt;, and &lt;em&gt;grid-column-end&lt;/em&gt;, in the styling of 1st cell item and assigned those properties to 1- and 3-unit attributes. This made the 1st cell item spread out from the 1st cell to the 2nd cell, as you can observe in the example.&lt;/p&gt;

&lt;p&gt;With the help of these grid-column and grid-row properties, you can create endless possibilities of layouts by creating different combinations of these properties. This is how CSS Grid becomes a helping hand to develop layouts and makes it so much easy.&lt;/p&gt;

&lt;p&gt;Until now, we have been talking about how the CSS Grid model helps us create complex ways much more effortless. But that’s not the only area in which CSS Grid benefits us. Perfectly aligning items in the layout is as important as the layout itself. Although CSS offers us a variety of properties for the alignment of items, in many cases, aligning items with these properties becomes a headache.&lt;/p&gt;

&lt;p&gt;CSS Grid model becomes a savior for us there too. The CSS Grid model comprises unique properties that make it much easier to align the items inside the cells. So now, let us discuss how items could be aligned in the CSS Grid Layout Model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aligning items&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In layout, aligning items with traditional CSS properties has always been a torturing thing for the developers. Positioning one item could ultimately lead to dispositioning its adjacent items if you use the conventional &lt;a href="https://www.lambdatest.com/blog/css-position-sticky-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS positioning&lt;/a&gt; properties. But CSS Grid is there too to have our back.&lt;/p&gt;

&lt;p&gt;CSS Grid comprises a collection of properties to align the items in the cell. These properties can be used to align the items in horizontal and vertical directions.&lt;/p&gt;

&lt;p&gt;As we have discussed above, in a grid layout, there are two major compartments — 1st one is the container div working as the wrap for all the cells, and the 2nd major compartment is the cells themselves. On that account, for both these major compartments, there are different properties for the alignment of the items. The align properties made for the container block will only work for the container and not the cells; the same goes for the properties made for the cell compartment.&lt;/p&gt;

&lt;p&gt;When it comes to aligning items properties, the first property that comes into play is the ‘&lt;em&gt;justify-items&lt;/em&gt;’ property. This property is used to align the items in the horizontal direction. This property falls under the category of container properties. So that means it will not be for a particular item; rather, it will affect all the items inside the container. That’s why the property name has ‘&lt;em&gt;items&lt;/em&gt;’ (plural).&lt;/p&gt;

&lt;p&gt;The justify-items property comprises many pre-defined keyword attributes for the different positioning of the items. The predefined attributes are listed below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;start&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;center&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;end&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;normal&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;stretch&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;baseline&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;auto&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;inherit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;initial&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these attributes help in aligning the items horizontally. At the default stage, all the items are fixed to the start attribute.&lt;/p&gt;

&lt;p&gt;Let’s see how it’s working with this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;1&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;2&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;3&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  height: 350px;
  width: 550px;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  justify-items: center;
  border: 2px solid black;
}


.item {
  border: 1px solid black;
  text-align: center;
  font-size: 40px;
  height: 50px;
  grid-row-start: 2;
  grid-row-end: 6;
  width: 50px;
  background-color: aqua;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IPDnIj4m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AHqA9k7Odj5foN9EB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IPDnIj4m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AHqA9k7Odj5foN9EB.png" alt="image" width="706" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you will notice that in the styling of container class, we have used the justify-items property and assigned it to the center attribute. This has aligned all the items in the container to the center. By using the start attribute, the items will get aligned to the left, and in the case of the end attribute, all the items will get aligned to the right.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;test automation tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now the question comes, how can we align a particular cell item without affecting the rest? The answer to this is “&lt;em&gt;justify-self&lt;/em&gt;” property. This cell-centric property does not affect the rest of the items except the item in which it is used. The &lt;em&gt;justify-self&lt;/em&gt; property works exactly like the justify-items property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;1&amp;lt;/div&amp;gt;
      &amp;lt;div class="item item1"&amp;gt;2&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;3&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.item1 {
  justify-self: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--baREpcZF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AFsz8TrsH3DAowKIA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--baREpcZF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AFsz8TrsH3DAowKIA.png" alt="image" width="708" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can notice that in the 2nd, we have used the justify-self property and assigned it to the center attribute. Because of this, the 2nd div is aligned to the center position in the cell. Since we have not assigned any, align property in the container div. Therefore the rest of the items are at their default alignments.&lt;/p&gt;

&lt;p&gt;As discussed above, the justify property works for the horizontal alignment. So, for the vertical alignment of the items, CSS Grid has aligned properties for us. The align properties allow us to align the items vertically. And just like the justify property, align-items too has two versions — align-items property for the container block and align-self property for the cells.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h2&amp;gt;Container 1&amp;lt;/h2&amp;gt;
    &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;1&amp;lt;/div&amp;gt;
      &amp;lt;div class="item item1"&amp;gt;2&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;3&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;h2&amp;gt;Container 2&amp;lt;/h2&amp;gt;
    &amp;lt;div class="cont"&amp;gt;
      &amp;lt;div class="item"&amp;gt;1&amp;lt;/div&amp;gt;
      &amp;lt;div class="item item2"&amp;gt;2&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;3&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  height: 350px;
  width: 550px;
  display: grid;
  border: 2px solid black;
  grid-template-rows: repeat(6, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  align-items: end;
}
.cont {
  border: 2px solid black;
  margin-top: 20px;
  height: 350px;
  width: 550px;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
}


.item {
  border: 1px solid black;
  text-align: center;
  font-size: 40px;
  height: 50px;
  grid-row-start: 2;
  grid-row-end: 6;
  width: 50px;
  background-color: aqua;
}


.item1 {
  justify-self: center;
}


.item2 {
  align-self: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b0H1i4ss--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ASv5NRr89pwuAONeN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b0H1i4ss--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ASv5NRr89pwuAONeN.png" alt="image" width="572" height="835"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, we have created two main container blocks, and in that, we have performed some basic styling on the items. Now comes the fun part. In the first container, we have embedded the align-items property and assigned it to the end attribute, which has shifted all the items to the vertical end of the cells. And for the 2nd container block, we have used the align-self property in the 2nd div and assigned it to the center attribute. This has made the 2nd div align at the center vertically. You can witness the difference between using the align-items property and the align-self property.&lt;/p&gt;

&lt;p&gt;Till now, we have been discussing all the examples by expecting the rows and columns to be in the fraction size of the grid. Fractions depend on the grid container’s size, so it keeps changing depending on the grid container’s size. But the tables get slightly turned if we consider the rows and columns to be in non-flexible units such as pixels.&lt;/p&gt;

&lt;p&gt;Sometimes, the size of the grid items is in a non-flexible unit (pixels) which results in the grid of less size as compared to the size of the grid container. In such cases, the grid’s alignment can be set within the grid container.&lt;/p&gt;

&lt;p&gt;Just like the CSS Grid offers some inbuild properties for the alignment of items when rows and columns are in fraction size, it has some alignment properties even when the rows and columns are in non-flexible units. CSS Grid majorly comes with two primary properties for the alignment of the content — justify-content property and align-content property.&lt;/p&gt;

&lt;p&gt;The justify-content property works the same way for the content as the justify-items for the cell items. The Justify-content property allows us to align the grid in the horizontal direction or, in other words, row-wise direction. And as you might have judged, the align-content property is responsible for aligning the grid in the vertical or column-wise direction. Let’s see these properties in action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  height: 250px;
  width: 550px;
  border: 2px solid black;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  justify-content: center;
}
.container2 {
  height: 250px;
  width: 550px;
  border: 2px solid black;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  align-content: center;
}


.item {
  border: 1px solid black;
  text-align: center;
  font-size: 40px;
  height: 50px;
  grid-row-start: 2;
  grid-row-end: 6;
  width: 50px;
  background-color: aqua;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZU9Bmp9L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AL1zVYXZUQnZgLfbr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZU9Bmp9L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AL1zVYXZUQnZgLfbr.png" alt="image" width="572" height="840"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we have created two container blocks, one for the justify-content property and the other for the align-content property. To make the effect of the justify-content and align-content properties visible, we have initialized the grid-template-rows and grid-template-columns properties with pixel quantities in place of fraction quantities.&lt;/p&gt;

&lt;p&gt;Check our comprehensive step-by-step guide on &lt;a href="https://www.lambdatest.com/blog/css-color-contrast/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS Color-Contrast()&lt;/a&gt;, which helps you create accessible user interfaces.&lt;/p&gt;

&lt;p&gt;Taking the 1st container block into consideration, we have initialized the justify-content property in the styling of the container block and assigned it to the center attribute. As a result, all the grid items will get aligned to the center. And now, no matter what the size of the row and columns will be (in pixels), the items inside the grid cells will always be aligned in the center.&lt;/p&gt;

&lt;p&gt;In the case of the 2nd container, we have used the align-content property to align items. To align the items vertically, in case of the non-flexible unit size of row and grid, we have the align-content property. The align-content property works exactly like the justify-content property but in the vertical direction.&lt;/p&gt;

&lt;p&gt;Just like other alignment properties, justify-content property, and align-content property too comes with a pack of attributes. Mentioned below is the list of attributes that these properties come with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;center&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;start&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;end&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;left&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;right&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;space-between&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;space-around&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;space-evenly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;stretch&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these properties work as a helping hand to align the elements at distinct positions.&lt;/p&gt;

&lt;p&gt;Until now, we have discussed a couple of different methods to align the grid items in horizontal and vertical positions. But still, there’s one major concept left to discuss: how to align a div block at the center. Let’s look at it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Centering a div&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Placing a div block at the center of a container has always been in practice to give the whole layout a professional look. But placing a div at the exact center position is very annoying. If we use traditional methods of CSS, aligning a div block at the center is nothing less complicated than aligning div blocks at different positions on the layout. But CSS Grid layout becomes our lifejacket even in this situation.&lt;/p&gt;

&lt;p&gt;The properties we discussed earlier help us to align the item in the horizontal and vertical directions. The same properties could also be used to align a div block at the center position of a container block. You may have guessed it; we can use both the horizontally and vertically aligning properties simultaneously to align a div at the center.&lt;/p&gt;

&lt;p&gt;Let’s understand it with an example shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div class="container1"&amp;gt;
      &amp;lt;div class="item"&amp;gt;1&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;2&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;3&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .container1 {
  height: 350px;
  width: 550px;
  display: grid;
  border: 2px solid black;
  grid-template-rows: repeat(5, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  justify-items: center;
  align-items: center;
}


.item {
  border: 1px solid black;
  text-align: center;
  height: 50px;
  font-size: 40px;
  grid-row-start: 2;
  grid-row-end: 4;
  width: 50px;
  background-color: aqua;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--auIKoClq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ACtJJzxd1UjrzweeQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--auIKoClq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ACtJJzxd1UjrzweeQ.png" alt="image" width="570" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, all three div blocks are exactly equidistant from both horizontal and vertical directions. And to get this effect, we have initialized both the justify-items property and align-items property in the styling of the main container block and assigned them to the center attribute. The justify-items property centered the block horizontally, and the align-items property centered the items vertically, and with the combined effect of these, we got this result.&lt;/p&gt;

&lt;p&gt;Now, let’s take an example where we have to center a specific item and not all.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="item"&amp;gt;1&amp;lt;/div&amp;gt;
      &amp;lt;div class="item item1"&amp;gt;2&amp;lt;/div&amp;gt;
      &amp;lt;div class="item"&amp;gt;3&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  margin-top: 20px;
  height: 350px;
  width: 550px;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  grid-template-columns: repeat(3, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  border: 2px solid black;
}


.item {
  border: 1px solid black;
  text-align: center;
  height: 50px;
  font-size: 40px;
  grid-row-start: 2;
  grid-row-end: 4;
  width: 50px;
  background-color: aqua;
}


.item1 {
  justify-self: center;
  align-self: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xtFxQJdh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ABAb6FCoI7zegfrD-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xtFxQJdh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ABAb6FCoI7zegfrD-.png" alt="image" width="706" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can notice that only the 2nd div block is aligned at the center. The rest of the div blocks are aligned at their default positions. To get this kind of effect, we have used the justify-self property and align-self property and assigned them to the center attribute. And that’s how we got this result.&lt;/p&gt;

&lt;p&gt;Finally, by using &lt;strong&gt;display: grid&lt;/strong&gt; with the CSS Display Property, web developers can create complex page layouts by defining rows and columns and placing elements within them, making it helpful in creating visually appealing and functional websites.&lt;/p&gt;

&lt;p&gt;Now imagine how much time it would have taken if we tried to align a div block at the center using the traditional CSS alignment properties. It took us just two lines of code to center a div.&lt;/p&gt;

&lt;p&gt;In this way, the CSS Grid makes our life so much easier and saves time.&lt;/p&gt;

&lt;p&gt;You might be doubting whether the layouts created using CSS Grid layout are responsive. The layout will be fully responsive if you use flexible units like fr. This is one more reason for using Grid layout mode to create a layout since there is no need to apply &lt;a href="https://www.lambdatest.com/blog/css-media-queries-for-responsive-design/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS media queries&lt;/a&gt; for the different screen sizes.&lt;/p&gt;

&lt;p&gt;After successfully creating a layout, testing its responsiveness on different screen sizes is highly important. But testing at different &lt;a href="https://www.lambdatest.com/screen-resolution-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;screen sizes and resolutions&lt;/a&gt; takes a lot of time and is quite tricky. To help us out in this situation, some testing and &lt;a href="https://www.lambdatest.com/blog/top-web-development-tools-for-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;web development tools&lt;/a&gt; are present in the market, making the whole testing procedure much easier and less time-consuming.&lt;/p&gt;

&lt;p&gt;One such tool available in the market is &lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;LT Browser 2.0&lt;/a&gt;. It is a &lt;a href="https://www.lambdatest.com/mobile-friendly-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;mobile-friendly tester&lt;/a&gt; that becomes a helping hand when performing &lt;a href="https://www.lambdatest.com/learning-hub/responsive-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;responsive testing&lt;/a&gt; of any web product.&lt;/p&gt;

&lt;p&gt;LT Browser by LambdaTest offers 50+ pre-installed viewports for mobiles, tablets, desktops, and laptops, which helps us to test our web product on different viewports and other features like network simulation, hot reloading, creating Google Lighthouse performance reports, and much more. Not just for testing purposes but many more reasons make the &lt;a href="https://www.lambdatest.com/blog/11-reasons-to-use-lt-browser/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;LT Browser a must for every developer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this article, we take a look at some aspects of simulation and discuss some ways through which we can use the&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/iphone-simulators-on-windows/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;iPhone emulator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h_tVL7yB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ALrDx1ut_Lc9q8e3m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h_tVL7yB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ALrDx1ut_Lc9q8e3m.png" alt="image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To learn more about Responsive Testing, watch the tutorial below:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ExPeFxpsdpY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can also subscribe to our &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube"&gt;LambdaTest YouTube Channel&lt;/a&gt; to learn about web automation tools like &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Selenium&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Playwright&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_21ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts!
&lt;/h3&gt;

&lt;p&gt;Congratulations on reaching this far! You’re a fantastic reader! In this tutorial, we’ve discussed the CSS Display Property and CSS Grid model layout in detail, including the different components of the CSS Display Property and CSS Grid with real-time examples. We also looked at how we can utilize the benefits of the CSS Grid layout model to create website layouts in a much easier and time-saving manner.&lt;/p&gt;

&lt;p&gt;We also discussed how CSS Grid saves our time by eliminating the need to assign media queries. We can check the Grid layout’s responsiveness using web development tools like LT Browser 2.0. Thanks for taking the time to read this article to completion. Feel free to ask questions in the comment below, and I’ll gladly reply.&lt;/p&gt;

&lt;p&gt;Happy Testing!  &lt;/p&gt;

&lt;h1&gt;
  
  
  LambdaTestYourApps
&lt;/h1&gt;

</description>
      <category>css</category>
      <category>cssdisplay</category>
      <category>autoamtiontesting</category>
      <category>cssdisplayproperty</category>
    </item>
    <item>
      <title>A Complete Guide To CSS Headers</title>
      <dc:creator>ayush-tha</dc:creator>
      <pubDate>Thu, 20 Apr 2023 08:20:36 +0000</pubDate>
      <link>https://dev.to/ayushtha/a-complete-guide-to-css-headers-kop</link>
      <guid>https://dev.to/ayushtha/a-complete-guide-to-css-headers-kop</guid>
      <description>&lt;p&gt;One of the integral aspects of a web product is to build an ever-lasting mesmerizing experience. When you open any website, your first touch point is the website’s header. Whether making an eCommerce business, SaaS business, or a simple portfolio website, you want the header to do the talking for you.&lt;/p&gt;

&lt;p&gt;Does this mean that the content, footer, and other aspects are unimportant? Well, they are! If all these integral elements of the website are well-presented to the end users, it will surely make a lasting impression. This guide will discuss building a responsive CSS header.&lt;/p&gt;

&lt;p&gt;In my experience, the header plays an integral role in devising a challenging user journey. Time spent on site, page, returning visitors, etc., are some key metrics that provide a glimpse of the website’s performance. If I were to compare, it is equivalent to comparing the footfalls in a shopping mall; the higher the footfall, the better our chances of generating sales.&lt;/p&gt;

&lt;p&gt;Your website is similar to an outlet in a shopping mall where the visitors have several choices up their sleeves. According to a report, a delay of one second in the page load time causes a close to 16% decrease in customer satisfaction and an 11% reduction in page views. All of this can cause a dent in the overall conversion rate.&lt;/p&gt;

&lt;p&gt;With so much at stake, it is imperative to focus on designing a website with a header, content, footer, and other elements that yield maximum website stickiness. CSS is the secret sauce that can be used with JavaScript and HTML to develop WOWsome websites.&lt;/p&gt;

&lt;p&gt;This CSS tutorial focuses on building super responsive CSS headers that can work seamlessly across different browsers and devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your native, hybrid, and web apps across all legacy and latest mobile operating systems on the most powerful Android&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;emulator online&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction to CSS Header
&lt;/h3&gt;

&lt;p&gt;The CSS header is a collection of several CSS and HTML properties that helps in the structuring of a website header. Everything in the CSS header, like the logo, text, menu, etc., are just blocks.&lt;/p&gt;

&lt;p&gt;In fact, the CSS header is a block itself, and these blocks can be styled with the CSS header properties.&lt;/p&gt;

&lt;p&gt;Here are examples of desktop and mobile views of website headers spanning various industries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1&lt;/strong&gt; — LambdaTest (Software-As-A-Service)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7mk6RhiV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AtAcmq9XavODUfmer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7mk6RhiV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AtAcmq9XavODUfmer.png" alt="image" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2&lt;/strong&gt; — Shopify (E-Commerce)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3SYxNFHz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AW4vCNfXLg0cLALI5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3SYxNFHz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AW4vCNfXLg0cLALI5.png" alt="image" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 3&lt;/strong&gt; — Nvidia (Semiconductors)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TUSle-PX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ApOUeMMrAwBrB5DOJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TUSle-PX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ApOUeMMrAwBrB5DOJ.png" alt="image" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 4&lt;/strong&gt; — Asana (Work management platform)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---mmO30PM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AyS53zaEupIteHhhS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---mmO30PM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AyS53zaEupIteHhhS.png" alt="image" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 5&lt;/strong&gt; — GitHub (Web hosting service)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VnKCnsaP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AbeT4HUmt0LQ0FRx_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VnKCnsaP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AbeT4HUmt0LQ0FRx_.png" alt="image" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the headers of every website (listed above) have a unique menu design. Clicking on the menu and submenus takes you to the particular product’s pillar page or provides the reader with more information about what’s in store for them on that very page.&lt;/p&gt;

&lt;p&gt;Akin to the header, the footer is also an integral part of any website. Though the items listed in the footer might vary from industry to industry, some of the everyday items that must be a part of the footer are Sitemap, Privacy Statement, Copyright notice, links to pages that are important for conversions (or lead generation), etc.&lt;/p&gt;

&lt;p&gt;Take the case of the footer on the website of LambdaTest — a continuous quality testing platform. Apart from the links to Careers, Status (that indicates the operational status of each product), etc., there are links to pillar pages that let the visitors perform browser &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;automation testing&lt;/a&gt; and &lt;a href="https://www.lambdatest.com/mobile-automation-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;mobile automation testing&lt;/a&gt;. Links to &lt;a href="https://www.lambdatest.com/learning-hub/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;LambdaTest Learning Hub&lt;/a&gt; navigates the visitor to the appropriate hub so that s/he can get a glimpse into the technical aspects of &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CI/CD&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Selenium&lt;/a&gt;, Cypress, and more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PxOtmVxD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A6bv9UoOaUqBvYLPk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PxOtmVxD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A6bv9UoOaUqBvYLPk.png" alt="image" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the platform all set, let’s dive deep into the essential aspects of CSS headers and footers. Most of the blog is focused on CSS header, a post in which we would touch upon CSS footer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this tutorial, learn what is&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;Regression test&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its importance, types, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Components Of CSS header properties
&lt;/h3&gt;

&lt;p&gt;As you might have noticed from the examples cited in the previous section, a header consists of textual content, relevant tags, logo, images, social media icons, and more.&lt;/p&gt;

&lt;p&gt;Some of the most critical components of the CSS header are mentioned below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Header Tag
&lt;/h3&gt;

&lt;p&gt;Just like every organization, its name is integral to it. The website header also features the organization’s name as its primary text. CSS header property comprises a feature known as Header tags &lt;code&gt;&amp;lt; header &amp;gt;&lt;/code&gt; that lets you insert the organization’s name in the header.&lt;/p&gt;

&lt;p&gt;Optimal usage of the &lt;code&gt;&amp;lt; header &amp;gt;&lt;/code&gt; tag will significantly impact the SEO (Search Engine Optimization) rankings! I have covered those aspects in later sections of this guide.&lt;/p&gt;

&lt;p&gt;Header tags are of 6 different types (H1-H6), with six different font sizes. Let’s see the header tags in action with the help of an example.&lt;/p&gt;

&lt;p&gt;As seen below, the biggest font size and the size continuously decreases with the tags until the H6 tag, whose font size is the smallest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZLSu4HqO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AUvLUIEGB726In8HX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZLSu4HqO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AUvLUIEGB726In8HX.png" alt="image" width="512" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another use of header tags in the CSS header is to insert a tagline. A tagline is like a short phrase that communicates the core aspects of your business. Many businesses use taglines as a way of communicating with their customers.&lt;/p&gt;

&lt;p&gt;A tagline is the first thing that your potential customers notice when they find out about your brand. Therefore, it’s crucial to ensure that your tagline must define what your business does and why someone should choose it. In addition, incorporating a CTA can help increase your leads and conversions.&lt;/p&gt;

&lt;p&gt;In many cases, you will observe that instead of the organization’s title, taglines are the major text on the header, and the organization’s title is used in the logo. Therefore, the primary use of header tags is to insert the tagline in the header. However, when it comes to putting up the logo, we will discuss it later in this blog.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='tagline'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The header tags act as a marker and help the browser recognize and read the important keywords and rank the website for that keywords. Therefore, using at least one header tag (out of H1-H6) on the webpage is always suggested.&lt;/p&gt;

&lt;p&gt;Header tags make it easier for search engine bots to crawl across the webpage, understand the keywords, and then rank the webpage based on the crawled information.&lt;/p&gt;

&lt;p&gt;Crawling a whole long paragraph is a bit difficult task for the bot, and the header tags make it easy by marking up the few critical keywords for the bot, thereby positively impacting the SEO.&lt;/p&gt;

&lt;h3&gt;
  
  
  Paragraph Tag
&lt;/h3&gt;

&lt;p&gt;After the tagline, the next major component of the website header is a short description of the company. By reading this description, visitors get an indication of the services and/or products the business offers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_vB-ryIn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AUnhvymThH7oznajr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_vB-ryIn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AUnhvymThH7oznajr.png" alt="image" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The font size of the description text is smaller than the tagline text, and to get the desired result, CSS header properties have a component named Paragraph tag (&lt;code&gt;&amp;lt; p &amp;gt;&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='tagline'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='desc'&amp;gt;
    &amp;lt;p&amp;gt;
      This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website 
    &amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can notice in the above example that we have inserted a description just below the tagline (which is in H1) because this makes the user immediately read the description just after reading the tagline. In some sense, content in the &lt;code&gt;&amp;lt; p &amp;gt;&lt;/code&gt; is a logical extension of what is mentioned under &lt;code&gt;&amp;lt; h1 &amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;You may wonder why we cannot use the H6 tag instead of the paragraph tag&lt;/p&gt;

&lt;p&gt;since both have small font sizes. You can do it. However, header tags are relatively heavier than paragraph tags.&lt;/p&gt;

&lt;p&gt;Using a paragraph tag will give the same result and significantly reduce the weight of the website header. Using these best practices further helps in reducing the page load time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;automated testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Header Background
&lt;/h3&gt;

&lt;p&gt;As the largest component of any website header, the header background is the most visible and the first thing a visitor comes in contact with whenever s/he lands on the website. You can insert either a media or color in the background. First, let’s talk about the media.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Np6xT6i_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AR_KUT8LCvKUw9rGw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Np6xT6i_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AR_KUT8LCvKUw9rGw.png" alt="image" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In media, you have the options of images, videos, and gifs to fill in the header background. Using an image as the background is always good practice. Sometimes an image can also be used as a mode to convey a message, tell a story, or sometimes invoke specific emotions in the user’s mind.&lt;/p&gt;

&lt;p&gt;Sometimes, the user feels personally connected with the image, which further connects the user to your business.&lt;/p&gt;

&lt;p&gt;We have the &lt;em&gt;background-image&lt;/em&gt; property in the CSS header properties to set an image as the background. Let’s understand it with the help of an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div{
  height: 500px;
  background-image: url('https://www.wallpapertip.com/wmimgs/68-682070_working-on-laptop-background.png')
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the background-image property has been used in the CSS file and is assigned to the URL address of the image within brackets. If you are planning to use an image in the background, then there are a few things you have to take care of.&lt;/p&gt;

&lt;p&gt;When inserting an image, it’s always a good practice to use lightweight images. Heavy images increase the website’s weight, significantly increasing the website’s loading time. This will eventually result in a bad user experience for the users. An increase in loading time also results in a higher bounce rate.&lt;/p&gt;

&lt;p&gt;Google search engine takes loading time as an essential factor in the website’s ranking. Therefore, an increase in the loading time will have an impact even on the ranking of the website. We all know the repercussions if the site is not ranking well on Google.&lt;/p&gt;

&lt;p&gt;Although you can insert images of any format, the ideal recommendation is to use Webp image format. WebP image format provides lossless and lossy compression for images on the web. Compared to PNG images, the Webp image format is 26% smaller. In short, Webp image format offers all the features that other format images do at a much smaller size.&lt;/p&gt;

&lt;p&gt;Because of the same reason, it’s always advisable to avoid using gifs and videos on the website.&lt;/p&gt;

&lt;p&gt;Now, let’s discuss the case of colored header backgrounds.&lt;/p&gt;

&lt;p&gt;Like an image, the colors also play a vital role in inviting emotions into the user’s mind. This is where Color Psychology comes into play. Color Psychology studies color and how a human brain reacts to the colors on the screen.&lt;/p&gt;

&lt;p&gt;Organizations are very well aware of the importance of colors and use them to play with our minds psychologically. Businesses choose the color that best matches the brand personality and triggers the desired emotion in the visitor’s mind.&lt;/p&gt;

&lt;p&gt;A real-life example of this is the company’s logos. You may have noticed many social media organizations use the blue color in their logos. That is because the blue color triggers refreshing, friendly, and inviting emotions in the user’s mind, and that’s exactly what social media sites want.&lt;/p&gt;

&lt;p&gt;Similarly, many food-tech organizations use red and yellow colors in their logos — survey. This is because the red color triggers hunger and appetite emotion in humans, and yellow triggers the emotion of happiness and friendliness.&lt;/p&gt;

&lt;p&gt;It is suggested that you use bright colors if you have a personal blog or website and a professional business website, then go with deep-toned colors like #752121, 035039, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;tools for automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QhlUeAhD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AOeZgRmTkvKeVmb1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QhlUeAhD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AOeZgRmTkvKeVmb1s.png" alt="image" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ColorHexa&lt;/p&gt;

&lt;p&gt;The color you choose can change the impact of your website on the users.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;CSS background-color&lt;/em&gt; property can be used to set the color of the header background. In the background-color property, the color can be set in three different ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Color name [e.g., red].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hex value of color [e.g., #FF0000].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RGB value [e.g., rgb(255, 0, 0)].&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div{
  border: solid black 2px;
  height: 200px;
  width:450px;
  float: left;
  text-align: center;
 padding-top: 100px;
  font-size: 50px;
  font-weight: bold;
}
.div1{
  background-color: #FF0000;
}
.div2{
  background-color: red;
}
.div3{
  background-color: rgb(255, 0, 0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the example, the three ways of defining background color have been shown. In all three divs, three different ways of assigning color have been shown — Hex value in 1st &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt;, color name in 2nd &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt;, and RGB value in 3rd &lt;code&gt;&amp;lt; div &amp;gt;&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
Let’s add a background color to the sample code we created earlier to demonstrate the usage of &lt;code&gt;&amp;lt; header &amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt; p &amp;gt;&lt;/code&gt; tags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='header'&amp;gt;
  &amp;lt;div class='text'&amp;gt;
  &amp;lt;div class='tagline content'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='desc'&amp;gt;
    &amp;lt;p&amp;gt;
      This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website 
    &amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can notice that we have added the background color in the header using the hex value of color.&lt;/p&gt;

&lt;p&gt;Now, how many colors should one use on his website header? As per the source, you can use the utmost two or three colors on your website. It’s always recommended to use at most two colors in the website header, whether a professional website or a personal blog while keeping the text in white or black.&lt;/p&gt;

&lt;p&gt;One exceptional case of this is if you want to use white color in the header. White is the default color in the elements, so if you plan to add a white color to the background, you don’t need to define the background color. Just make sure that the header background should suit the other elements of the header.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;automation testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Company’s logo
&lt;/h3&gt;

&lt;p&gt;A logo is a graphic symbol that can help your business stand out from its competitors. A logo represents an organization’s identity and vision and should express the core elements of the business. The human brain memorizes images much faster and longer than plain text. As per &lt;a href="https://www.t-sciences.com/news/humans-process-visual-data-better#:~:text=In%20fact%2C%20the%20human%20brain,data%20processing%20and%20organizational%20effectiveness."&gt;research&lt;/a&gt;, the human brain memorizes images 60,000 times faster than text, benefiting the business.&lt;/p&gt;

&lt;p&gt;These factors help in having a faster brand recall, a factor that is so integral in today’s hyper-competitive business environment.&lt;/p&gt;

&lt;p&gt;Using a logo in the header has many benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Increase user (or customer) stickiness.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Brand Recall.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Foster brand loyalty.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Foundation of brand’s identity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gain competitive advantage.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CSS header properties have an inbuilt feature known as an Image tag (&lt;/p&gt;

&lt;p&gt;), which helps to insert images in the header.&lt;/p&gt;

&lt;p&gt;Let’s understand it’s working with the help of an example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HCkUAcNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ACwdo-4OZQSx8VuVy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HCkUAcNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ACwdo-4OZQSx8VuVy.png" alt="image" width="800" height="215"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='header'&amp;gt;
  &amp;lt;div class='nav'&amp;gt;
  &amp;lt;div class='li'&amp;gt;&amp;lt;img src="https://cdn-icons-png.flaticon.com/512/3159/3159614.png" style="width: 8%; padding-left: 20px; padding-right: 0px" alt='logo'/&amp;gt;
&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='text'&amp;gt;
  &amp;lt;div class='tagline content'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='desc'&amp;gt;
    &amp;lt;p&amp;gt;
      This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website 
    &amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see above, we have inserted the logo in the top-left corner using the image tag. The image tag demands two attributes — src and alt. In the src, the path where the image is stored is inserted and if the image is uploaded online, then simply put the image address.&lt;/p&gt;

&lt;p&gt;The second attribute is the alt, an alternative text that plays a crucial role in the website’s SEO ranking. It can be any keyword for which you want your website to rank.&lt;/p&gt;

&lt;p&gt;The image tag supports the following image formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;jpeg.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;png.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;apng.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;svg.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;bmp.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;bmp ico.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;png ico.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the question arises, where should you put the palace logo in the header? And the left side of the website header. It is the best and most suggested position to place the logo. As per the research, the chances of visitors recalling the logo on the left side is 89% more than on the right one.&lt;/p&gt;

&lt;p&gt;In case you have an animated logo or a gif logo, then you can insert it too through the image tag. Just make sure it should be of small size. The steps to insert a gif are the same as an image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src="https://www.galvanizeaction.org/wp-content/uploads/2022/06/Wow-gif.gif" alt='logo' /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Menu&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now comes with one of the most important elements of the header, “Menu” (or Navigation Bar). As the name suggests, the navigation bar works as a navigator for the visitors who have landed on the web page and helps them navigate to the relevant section on the site.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Without a navigation bar, the visitors will get confused about what they should do if they want to avail of any offer or buy (or try) a product. It will be like a person traveling to reach a destination, but he doesn’t know the route. He’ll surely get confused; the same happens to the visitor when he does not get the navigation bar on the header.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So to do that, there are some factors that one should follow when creating the navigation bar:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy navigation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid information overload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintain consistent spacing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clean and simple aesthetic looks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easily noticeable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Just like the logo and other key elements of the header are placed on the left side, the same rule is applied to the navigation bar. The most important options on the navigation bar should be on the left side, and the reason behind that is the same as other header components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To insert the menu, the list item tag (&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;) is used, and CSS styling is added to them to give it a navigation bar look. A navigation bar is of two types — horizontal and vertical. A horizontal menu is preferred for desktop view and a vertical for mobile view.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let’s see the construction of both navigation bars and how they work.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ET6pWucW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ABYH2XY-AIv_Zen4E.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ET6pWucW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ABYH2XY-AIv_Zen4E.png" alt="image" width="800" height="213"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='header'&amp;gt;
  &amp;lt;div class='nav'&amp;gt;
&amp;lt;ul&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;img src="https://cdn-icons-png.flaticon.com/512/3159/3159614.png" style="width: 8%; padding-left: 20px; padding-right: 0px"/&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#home"&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#home"&amp;gt;Outfits&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#news"&amp;gt;Fashion Trend&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#contact"&amp;gt;Contact Us&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a href="#about"&amp;gt;About Us&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
  &amp;lt;/div&amp;gt;

  &amp;lt;div class='text'&amp;gt;
  &amp;lt;div class='tagline content'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='desc'&amp;gt;
    &amp;lt;p&amp;gt;
      This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website 
    &amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can notice that we have inserted the horizontal navigation bar using the list item tag. It’s more like a horizontal strip containing all the menu options.&lt;/p&gt;

&lt;h3&gt;
  
  
  Call to Action
&lt;/h3&gt;

&lt;p&gt;A Call to Action or CTA is like a signpost that helps the user know what action to take next. CTA encourages the visitor to take immediate action. Many businesses want their users to take instant action without overthinking, and that’s where CTA comes into play.&lt;/p&gt;

&lt;p&gt;Through CTA, you can make your visitors perform any action through CTA — signing up or registering on the site, filling up a form, reading more, or something else.&lt;/p&gt;

&lt;p&gt;Many organizations also offer some free services to users if they register on the website. The free service can be a free pdf, a free demo of the product, a premium service trial, etc., and the users take the required action.&lt;/p&gt;

&lt;p&gt;As per a report by HubSpot, there was an increase in conversion rates by 121% because of CTAs.&lt;/p&gt;

&lt;p&gt;A CTA could be anything like a button, a clickable link, or anything else unless it makes the user take a specific action. When inserting a CTA, CSS header properties offer the Button tag (&lt;code&gt;&amp;lt; button &amp;gt;&lt;/code&gt;) tag.&lt;/p&gt;

&lt;p&gt;Let’s see the working of button tags with the help of an example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---b8C_v9m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Ai84Vch8JkSE3bvu3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---b8C_v9m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Ai84Vch8JkSE3bvu3.png" alt="image" width="800" height="215"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href='#register'&amp;gt;&amp;lt;button&amp;gt;Sign Up&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can observe, we have created a CTA button for Sign Up in the above example. Similarly, you can make any CTA button for your website header.&lt;/p&gt;

&lt;h3&gt;
  
  
  Social Media Icons
&lt;/h3&gt;

&lt;p&gt;Having a social media presence is as important as having a website for the business. Social media pages create trust in the user’s mind regarding the business.&lt;/p&gt;

&lt;p&gt;People feel more connected to the business when they land on its social media pages of the business. Linking your website header to its social media pages increases its brand exposure.&lt;/p&gt;

&lt;p&gt;There are numerous social media platforms where you can create your business page. But there are some social media platforms that experts widely suggest boost the business’s growth. These social media platforms include Instagram, Twitter, YouTube, and Facebook.&lt;/p&gt;

&lt;p&gt;Linking the social media pages to the header via social media icons is a great way to increase the trust in the visitor’s mind.&lt;/p&gt;

&lt;p&gt;CSS header properties allow us to add social media icons to the website header through the Link tag (&lt;code&gt;&amp;lt; a &amp;gt;&lt;/code&gt;). The link tag demands a linking attribute, ‘ahref,’ where the link is added.&lt;/p&gt;

&lt;p&gt;Several predefined free social media icon libraries are available on the internet, making it much easier to insert social media icons at the header. You just need to add the class name of the desired icon in the line tag.&lt;/p&gt;

&lt;p&gt;Let’s see this in action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RNEof7z9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AwRszLZw8wp_8Hczz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RNEof7z9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AwRszLZw8wp_8Hczz.png" alt="image" width="800" height="216"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='header'&amp;gt;
  &amp;lt;div class='nav'&amp;gt;
&amp;lt;ul&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;img src="https://cdn-icons-png.flaticon.com/512/3159/3159614.png" style="width: 8%; padding-left: 20px; padding-right: 0px"/&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#home"&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#home"&amp;gt;Outfits&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#news"&amp;gt;Fashion Trend&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#contact"&amp;gt;Contact Us&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a href="#about"&amp;gt;About Us&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;button&amp;gt;Sign up&amp;lt;/button&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
  &amp;lt;/div&amp;gt;

&amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"&amp;gt;

&amp;lt;a href="#" class="fa fa-facebook"&amp;gt;&amp;lt;/a&amp;gt;
  &amp;lt;a href="#" class="fa fa-twitter"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;a href="#" class="fa fa-youtube"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;a href="#" class="fa fa-instagram"&amp;gt;&amp;lt;/a&amp;gt;
  &amp;lt;div class='text'&amp;gt;
  &amp;lt;div class='tagline content'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='desc'&amp;gt;
    &amp;lt;p&amp;gt;
      This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website 
    &amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we have inserted circular social media icons. A free social media icon library has been used, as shown in the .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Do you use a Mac and want to run the test in Internet Explorer? This article explores how to test&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/test-internet-explorer-for-mac/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;Internet Explorer on Mac&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sticky Navigation
&lt;/h3&gt;

&lt;p&gt;You will notice that the navigation bar of many websites is sticky, irrespective of the fold in which the visitor is currently in! This is the feature that many organizations use on their website to make it easy for their visitors to always have access to the navigation bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IzRJbWW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A8PxDrngXM_gPHQlE.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IzRJbWW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A8PxDrngXM_gPHQlE.gif" alt="image" width="600" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many organizations like to keep the website’s navigation bar sticky, and many do not. It varies from company to company whether they want to keep the navigation bar sticky or not. Making the navigation bar sticky is independent of the type of the navigation bar.&lt;/p&gt;

&lt;p&gt;A sticky navigation bar has many advantages, such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Quicker navigation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce the chances of the user getting distracted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reminds the visitor to take immediate action.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Screen time on the website increases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The user has access to the navigation bar all the time&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As per the report, once a major business website made a minor change in their website by making the navigation bar sticky. This slight change made the visitors pay extra attention to each product listed on the website.&lt;/p&gt;

&lt;p&gt;This eventually increased the screen time of the website. As a result, the company saw a significant reduction in the bounce rate and an increase in conversion rate of 10%.&lt;/p&gt;

&lt;p&gt;CSS position property helps in making the header sticky. You just need to add a single line of code in the CSS file to make your navigation bar sticky. Just add the position property to the navbar element and assign it to the sticky attribute.&lt;/p&gt;

&lt;p&gt;Here’s an example showing how to create a sticky navigation bar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
  &amp;lt;nav&amp;gt;
    &amp;lt;ul&amp;gt;
      &amp;lt;li&amp;gt;Home&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;About Us&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;Contact Us&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;Privacy Policy&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
  &amp;lt;/nav&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;h2&amp;gt;Introduction&amp;lt;/h2&amp;gt;
  &amp;lt;p&amp;gt;Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. &amp;lt;/p&amp;gt;

  &amp;lt;h2&amp;gt;Why do we use it?&amp;lt;/h2&amp;gt;

&amp;lt;p&amp;gt;It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).&amp;lt;/p&amp;gt;
  &amp;lt;br&amp;gt;

  &amp;lt;h2&amp;gt;Where does it come from?&amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt;Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the final code that takes into account the various CSS components that we described so far (i.e. &lt;code&gt;&amp;lt; header&lt;/code&gt; &amp;amp;gt;, &lt;code&gt;&amp;lt; p &amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt; img &amp;gt;&lt;/code&gt;, etc.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='header'&amp;gt;
  &amp;lt;div class='nav'&amp;gt;
&amp;lt;ul&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;img src="https://cdn-icons-png.flaticon.com/512/3159/3159614.png" style="width: 8%; padding-left: 20px; padding-right: 0px"/&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#home"&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#home"&amp;gt;Outfits&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#news"&amp;gt;Fashion Trend&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a class="active" href="#contact"&amp;gt;Contact Us&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;a href="#about"&amp;gt;About Us&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;button&amp;gt;Sign up&amp;lt;/button&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
  &amp;lt;/div&amp;gt;

&amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"&amp;gt;

&amp;lt;a href="#" class="fa fa-facebook"&amp;gt;&amp;lt;/a&amp;gt;
  &amp;lt;a href="#" class="fa fa-twitter"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;a href="#" class="fa fa-youtube"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;a href="#" class="fa fa-instagram"&amp;gt;&amp;lt;/a&amp;gt;
  &amp;lt;div class='text'&amp;gt;
  &amp;lt;div class='tagline content'&amp;gt;
    &amp;lt;h1&amp;gt;One Stop 
      &amp;lt;br&amp;gt;
      For Fashion Lovers
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='desc'&amp;gt;
    &amp;lt;p&amp;gt;
      This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website. This is dummy text for the description of the website 
    &amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;div class='content'&amp;gt;
    &amp;lt;img src='https://cdn-icons.flaticon.com/png/512/4515/premium/4515505.png?token=exp=1659973463~hmac=04833a7ad09897d78b8373c57a3a84d8' alt='image'  class ="image"/&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Responsive web design
&lt;/h3&gt;

&lt;p&gt;Nowadays, the number of mobile users is much higher than the number of desktop users. As per the report, 58% of online visits came from mobile users in 2021. And these numbers will keep on increasing.&lt;/p&gt;

&lt;p&gt;Therefore, you must create a &lt;a href="https://www.lambdatest.com/blog/responsive-web-design-all-you-need-to-know/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;responsive web design&lt;/a&gt; to ensure a mind-blowing experience across different screen sizes and resolutions. Thankfully, CSS has got a solution for this too. It comes up with the feature of &lt;a href="https://www.lambdatest.com/blog/css-media-queries-for-responsive-design/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS media queries&lt;/a&gt; that will help you to make your website header responsive.&lt;/p&gt;

&lt;p&gt;This feature allows you to assign the different styling of the components depending upon the screen size. For a phone, you can assign different styling; for a tablet, you can assign different styling for the desktop or PC.&lt;/p&gt;

&lt;p&gt;Once you have designed the web page, you must run a &lt;a href="https://www.lambdatest.com/responsive-test-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;responsiveness test&lt;/a&gt; of your CSS header.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ExPeFxpsdpY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;However, testing responsiveness can be tedious as owning all devices of different screen sizes and resolutions is impractical. This is &lt;a href="https://www.lambdatest.com/mobile-friendly-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;mobile-friendly testers&lt;/a&gt; tools like &lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;LT Browser&lt;/a&gt; becomes a helping hand. It is a responsive testing tool offered by LambdaTest platforms; LT Browser offers 50+ pre-installed viewports for Mobiles, Tablets, Desktops, and Laptops.&lt;/p&gt;

&lt;p&gt;Need more reasons why you should use LT Browser? Here are the reasons &lt;a href="https://www.lambdatest.com/blog/11-reasons-to-use-lt-browser/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;why developers should use LT Browser&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ToqT0Ci---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AzJE206Uqw3uG2C3Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ToqT0Ci---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AzJE206Uqw3uG2C3Q.png" alt="image" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Intrigued to know more about LT Browser, watch the below tutorial.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/K1dlmU3QWWk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube"&gt;LambdaTest YouTube Channel&lt;/a&gt; and get the latest tutorial around &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;test automation&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Selenium&lt;/a&gt;, Cypress, &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Playwright browser testing&lt;/a&gt;, Mobile app testing, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping up
&lt;/h3&gt;

&lt;p&gt;In this CSS tutorial, we discussed the CSS header in detail, including the different components of the CSS header with real-time examples. We also discussed &lt;a href="https://www.lambdatest.com/blog/importance-of-responsive-web-design/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;why responsive web design is important&lt;/a&gt; for your organizations and how to perform responsive testing of CSS headers using &lt;a href="https://www.lambdatest.com/blog/top-web-development-tools-for-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr20_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;web development tools&lt;/a&gt; like LT Browser.&lt;/p&gt;

&lt;p&gt;I hope this CSS guide has given you a comprehensive understanding of the CSS header. Got any questions? Feel free to drop them in the comments section.&lt;/p&gt;

</description>
      <category>css</category>
      <category>cssheaders</category>
      <category>guide</category>
      <category>automationtesting</category>
    </item>
    <item>
      <title>An Interactive Guide To CSS Hover Effects</title>
      <dc:creator>ayush-tha</dc:creator>
      <pubDate>Wed, 19 Apr 2023 07:37:52 +0000</pubDate>
      <link>https://dev.to/ayushtha/an-interactive-guide-to-css-hover-effects-oja</link>
      <guid>https://dev.to/ayushtha/an-interactive-guide-to-css-hover-effects-oja</guid>
      <description>&lt;p&gt;Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.&lt;/p&gt;

&lt;p&gt;Adding animations to your website can make it more interesting and appealing to visitors. Not only will an animation make your website easier to use, but it will also make navigation simpler for users. By changing the text color, when someone moves their cursor over it, you can notify them which text is clickable and which is not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sgpb_P6p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AfiLUaacYHVmGamk_.png%2520align%3D%2522left%2522" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sgpb_P6p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AfiLUaacYHVmGamk_.png%2520align%3D%2522left%2522" alt="" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, how can you transform the plain sailing text on a web page into appealing text? The answer to the question lies with CSS hover effects that are a curation of some stunning animation properties. These can be embedded into any text and provide an amazing look. These simple yet impressive animation properties work as a visual treat for the visitors and enhance the user experience positively.&lt;/p&gt;

&lt;p&gt;You can loosely compare the impact of CSS hover effects to the animated banners you see outside shopping malls and outlets. Just like these blinking banners visually garners the attention of the intended audience, in the same way, the animated text benefits the website.&lt;/p&gt;

&lt;p&gt;Not just adding to animation in text, CSS hover effects also come in handy when we need to add a drop-down for better navigation.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/q-WoTPmYESc"&gt;
&lt;/iframe&gt;
 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your native, hybrid, and web apps across all legacy and latest mobile operating systems on the most powerful&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;Android online emulator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Does this mean the more the animation texts, the better the user experience? Well, maybe yes! But it’s also recommended not to add too much-animated text on the website; the proportion must be appropriate.&lt;/p&gt;

&lt;p&gt;In this guide, we will explore advanced properties of CSS hover animations like background clipping, masks, and 3D, along with detailed examples.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are CSS Hover Effects?
&lt;/h3&gt;

&lt;p&gt;CSS hover effects let you add some amazing eye-catching animations to texts, images, and links, irrespective of the type, length, and position of the placeholder. You can add animation to different text types, from header text to paragraph text to link text.&lt;/p&gt;

&lt;p&gt;It comes with endless possibilities for adding animations. You can customize the animation you want to add to the text, experiment with the text border and shadow, background color, font color, or any other text property, and alter it according to the animation you intend to add.&lt;/p&gt;

&lt;p&gt;The principles of the adage “Too much anything is bad” also apply to hover effects. As per my experience, you should use CSS hover effects only to the extent that it does not stray the user’s attention! Extensive usage of hover effects might dampen the end-user experience!&lt;/p&gt;

&lt;p&gt;Unlike standard animations that start when the webpage loads, hover animations begin when the user moves the control over the animated text. In other words, the hover animations come into view when the user brings the cursor over the animated text; before that, it would look like standard text.&lt;/p&gt;

&lt;p&gt;To add animations, CSS hover effects come with a pseudoclass named :hover that has to be assigned to the text. Post that, you need to add the animation properties to that pseudoclass.&lt;/p&gt;

&lt;p&gt;The following screenshot shows the working of CSS hover functionality on the LambdaTest website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nrDaNz83--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A3eEYSYpNTplwlFH_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nrDaNz83--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A3eEYSYpNTplwlFH_.png" alt="image" width="800" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example below, we have chalked out examples of the same texts with different CSS hover behavior. All four of these texts have different animations assigned in the &lt;em&gt;hover&lt;/em&gt; pseudoclass.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;style.css .container {
  font-size: 40px;
  width: 50%;
  text-align: center;
  padding-top: 10px;
  font-weight: bold;
  float: left;
  cursor: pointer;
}
.hover-1:hover {
  color: red;
  font-size: 30px;
  text-decoration: underline;
  text-decoration-style: dotted;
  transition: font-size 0.3s ease-out;
}
.hover-2:hover {
  color: #00ffff;
  text-decoration: underline;
  text-decoration-style: wavy;
  transition: color 0.5s ease-in;
}
.hover-3:hover {
  color: #25316d;
  background-color: #b1b2ff;
  border-radius: 20px;
  transition: all 0.5s ease-in;
}
.hover-4:hover {
  text-shadow: 2px 2px 8px #ff0000;
  border: 2px solid #a5f1e9;
  border-radius: 20px;
  color: #a5f1e9;
  transition: all 0.2s ease-in;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='container'&amp;gt;&amp;lt;p class='hover-1'&amp;gt;Hover Text 1&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;div class='container'&amp;gt;&amp;lt;p class='hover-2'&amp;gt;Hover Text 2&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class='container'&amp;gt;&amp;lt;p class='hover-3'&amp;gt;Hover Text 3&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;div class='container'&amp;gt;&amp;lt;p class='hover-4'&amp;gt;Hover Text 4&amp;lt;p&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Are you using&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;Playwright&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;for automation testing? Run your Playwright test scripts instantly on 50+ browser/OS combinations using the LambdaTest cloud. Sign up for free.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use CSS Hover?
&lt;/h3&gt;

&lt;p&gt;CSS hover effect lets you alter the style of an HTML element when hovered over by a cursor or other pointing device, such as a touch screen. Many HTML elements, including text, photos, and buttons, can be given this effect.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To create a CSS hover effect, you should first choose the HTML element to which you wish to apply the hover effect too. A CSS selector, such as “p” for a paragraph element or “.button” for a button element, can be used to accomplish the above.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, define the CSS styles you want to use when the element hovers over. This includes altering the element’s border color, font size, background color, text color, or any other visual attribute. To get the desired effect, you can combine any CSS attribute and value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To apply the hover effect to the selected element, you need to use the :hover pseudo-class in your CSS code. The styles that should be used when the element hovers over are specified by this pseudo-class, which is added to the element’s selector.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;when the element hovers over, the CSS styles given for the:hover pseudo-class is applied, displaying and making it more interactive for the user.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eventually, by enabling you to build dynamic visual effects that respond to user activities, employing CSS hover effects may add a lot of interactivity and engagement to a webpage.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the best CSS Hover Effect?
&lt;/h3&gt;

&lt;p&gt;The ideal CSS hover effect largely depends on the specific design and context of the project. Still, the following examples of well-liked hover effects might be beneficial:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sliding highlight links: This effect slides a highlight bar or box over the link when it is hovered over, creating a dynamic and interactive visual effect. It can be used to highlight crucial navigational links or components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Links with text-swapping effects: When a link has hovered over, this effect changes one piece of text for another, producing an entertaining and captivating visual effect. It can be utilized to give the design personality and humor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CSS hover effects with transitions: This effect uses CSS transitions to seamlessly animate changes in the element’s appearance, such as changes to color, opacity, or border radius. It can be utilized to provide refined, subdued visual effects that give the design a sense of expertise.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Image overlay hover effects: This effect provides a visual effect that draws attention to the image and stimulates user engagement by projecting text, buttons, or other items over an image when it hovers over. It can be used to display product photographs, make photo galleries, or even spice up the page’s visual appeal.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The best CSS hover effect for your project will ultimately depend on your design objectives and the particular project circumstances. While selecting a hover effect, it’s crucial to keep in mind the function and purpose of your design elements and the branding and target audience.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are CSS Advanced Effects?
&lt;/h3&gt;

&lt;p&gt;Now let’s understand the three CSS Advanced effects — Background Clipping, Masks, and 3D along with some detailed examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background-Clip
&lt;/h3&gt;

&lt;p&gt;First, let us take the case of animations with the background-clip property. As the name indicates, the background-clip property simply clips the background. CSS background-clip property allows us to set to what extent the background graphics will be applied.&lt;/p&gt;

&lt;p&gt;To see the magic of the background-clip property, simply set the background property to a graphical element and assign the background-clip property to the area where you want to make the graphic element visible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='text'&amp;gt;Hover Text&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above snippet, you can notice that we have assigned a three-colored linear gradient to the background. To make it visible only inside the text and not on the main background, we have applied the background-clip property and assigned the text attribute to it.&lt;/p&gt;

&lt;p&gt;We have fixed the font color of the text as transparent. It will generate a text of transparent color or a see-through text, which will ultimately make the assigned background graphics visible. If the font color is not assigned to transparent (#0000), then the text will be in default color (i.e., black), eventually hiding the background graphics.&lt;/p&gt;

&lt;p&gt;Not just the text area, you can also assign the background effect to different portions of the background by using the collection of attributes that the background-clip property offers.&lt;/p&gt;

&lt;p&gt;Attributes are mentioned below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;text&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;padding-box&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;border-box&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;content-box&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s see all these attributes in action with the help of an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div {
  font-size: 70px;
  background: linear-gradient(
    90deg,
    rgba(212, 2, 249, 1) 28%,
    rgba(250, 251, 61, 1) 53%,
    rgba(0, 212, 255, 1) 100%
  );
  font-family: Arial, Helvetica, sans-serif;
  padding-bottom: 0.1em;
  cursor: pointer;
  color: transparent;
  margin-top: 20px;
  font-weight: bold;
}
body {
  display: grid;
  place-content: center;
}
.text {
  text-align: center;
  background-clip: text;
  -webkit-background-clip: text;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='text'&amp;gt;Text&amp;lt;/div&amp;gt;
&amp;lt;div class='border-box'&amp;gt;Border-Box&amp;lt;/div&amp;gt;
&amp;lt;div class='content-box'&amp;gt;Content-Box&amp;lt;/div&amp;gt;
&amp;lt;div class='padding-box'&amp;gt;Padding-Box&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the text attribute, the gradient is visible only on the text portion. On the border-box attribute, the gradient is extended to borders, and in the same way, the gradient is stretched to its respective portions in the content-box and padding-box attributes.&lt;/p&gt;

&lt;p&gt;Now let us utilize these clipping properties and create some magical animations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h3 class="hover"&amp;gt;Hover Text&amp;lt;/h3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above snippet, as you hover over the text, you can see the smooth color shift in the text. Now let us look at what role background-clip property plays in creating this effect. We will proceed step-by-step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hover {
    color: #0000;
    background:
      radial-gradient(circle, rgba(212,2,249,1) 28%, rgba(250,251,61,1) 53%, rgba(0,212,255,1) 100%);
    transition: .4s;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initially, we initiated the &lt;code&gt;&amp;lt; h3 &amp;gt;&lt;/code&gt; tag, added an example text, and assigned some basic radial gradient styling as the background to this header tag. Also, as explained earlier in the CSS hover blog, we have assigned transparent as the font color to make the animation visible to us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; -webkit-background-clip: text;
            background-clip: text;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following the background styling, we added the position, size, and repeat attributes to the radiant-gradient property to improve the styling. In addition, the background-clip property has been added to the CSS styling assigned to the text property to get the gradient styling in the text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hover:hover {
    --c:100%;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To achieve the animation, we have converted the position attribute of the radial gradient from a static value to a dynamic value by creating &lt;a href="https://www.lambdatest.com/blog/guide-to-css-variables-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS variables&lt;/a&gt;. Its value is set to 0%.&lt;/p&gt;

&lt;p&gt;Afterward, to create the animation, hover pseudoclass is used to which we have assigned the defined variable to the value of 100%. So now, whenever the user hovers over the text, the value of the variable changes, and the animation becomes visible.&lt;/p&gt;

&lt;p&gt;Let’s take it a step further and add a visually appealing underline that appears when you hover over the text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Automated&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automated-functional-testing-what-it-is-how-it-helps/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;&lt;strong&gt;&lt;em&gt;Functional Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tests helps to ensure that your web app works as it was intented to. Learn more about functional tests, and how automating them can give you a faster release cycle.&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h3 class="hover"&amp;gt;Hover Text&amp;lt;/h3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this animation, the user hovers the cursor over the text, along with the animation in the text, a beautiful line appears just below the text. The line also features a beautiful color gradient just like the text. You can do all of this with just two lines of code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;radial-gradient(circle, rgba(212, 2, 249,1) 28%, rgba(250, 251, 61, 1) 53%,
rgba(0, 212, 255, 1) 100%) 0% 100%/var(--c, 0%) 0/1em no-repeat;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the previously defined gradient, we added a radial-gradient effect in the background property. This defined gradient will add the gradient to the bottom of the padding box. After that, we initialized a dynamic CSS variable in this gradient which will manipulate the size of the gradient. Now the only thing we need to update is the background-clip property.&lt;/p&gt;

&lt;p&gt;In the background-clip property, we have added the padding-box property so that the background effect stays visible only in the padding area. And finally, the hover pseudoclass is there to change the variable’s value as we hover over it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin:0 auto;
  cursor: pointer;
  padding: 0 .1em;
}

.hover-1{
  --c: #1095c1; 

  color: #0000;
  background: 
    linear-gradient(var(--c) 50%,#000 0) 0% calc(100% - var(--_p,0%))/100% 25%,
    linear-gradient(var(--c) 50%,#000 0) 0% calc(0% - var(--_c,100%))/100%
    no-repeat;
  -webkit-background-clip: text;
          background-clip: text;
  transition: .3s ;
}

.hover-1:hover{
   --_p: 100%;
  --_c:0%;
  --_s: .3s;
}

.hover-2{
   color:#0000;
  background: 
    linear-gradient(90deg,white 50%,black 0) 
    var(--_p,100%)/200%,
    linear-gradient(90deg,white 50%,black 0) 
    var(--_c,0%)/200%
    no-repeat;
  -webkit-background-clip: text,padding-box;
          background-clip: text,padding-box;
  transition: .4s;
}
.hover-2:hover {
 --_p: 0%;
--_c: 100%;
}
.hover-3{
    --c: #1095c1; 

  color: #0000;
  background: 
    linear-gradient(white 50%,#000 0) 0% calc(100% - var(--_p,0%))/100% 14%,
    linear-gradient(#ADDDD0 50%,#000 0) 0% calc(0% - var(--_c,100%))/100%
    25%;
  -webkit-background-clip: text,padding-box;
          background-clip: text,padding-box;
  transition: .5s ;
}

.hover-3:hover{
  --_p: 100%;
  --_c:0%;
}
.hover-4{
  color:black;
  background: 
    linear-gradient(90deg,red 50%,white 50%) 
    var(--_p,100%)/200%,
    linear-gradient(90deg,white 50%,red 50%) 
    var(--_c,0%)/200%
    no-repeat;
  -webkit-background-clip: text,padding-box;
          background-clip: text,padding-box;
  transition: .4s;
}
.hover-4:hover{
   --_p: 50%;
--_c: 50%;
  color:#0000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;style.css
body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin: 0 auto;
  cursor: pointer;
  padding: 0 0.1em;
}
.hover-1 {
  --c: #1095c1;
  color: #0000;
  background: linear-gradient(var(--c) 50%, #000 0) 0%
      calc(100% - var(--_p, 0%)) / 100% 25%,
    linear-gradient(var(--c) 50%, #000 0) 0% calc(0% - var(--_c, 100%)) / 100%
      no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  transition: 0.3s;
}
.hover-1:hover {
  --_p: 100%;
  --_c: 0%;
  --_s: 0.3s;
}
.hover-2 {
  color: #0000;
  background: linear-gradient(90deg, white 50%, black 0) var(--_p, 100%) / 200%,
    linear-gradient(90deg, white 50%, black 0) var(--_c, 0%) / 200% no-repeat;
  -webkit-background-clip: text, padding-box;
  background-clip: text, padding-box;
  transition: 0.4s;
}
.hover-2:hover {
  --_p: 0%;
  --_c: 100%;
}
.hover-3 {
  --c: #1095c1;
  color: #0000;
  background: linear-gradient(white 50%, #000 0) 0% calc(100% - var(--_p, 0%)) /
      100% 14%,
    linear-gradient(#adddd0 50%, #000 0) 0% calc(0% - var(--_c, 100%)) / 100%
      25%;
  -webkit-background-clip: text, padding-box;
  background-clip: text, padding-box;
  transition: 0.5s;
}
.hover-3:hover {
  --_p: 100%;
  --_c: 0%;
}
.hover-4 {
  color: black;
  background: linear-gradient(90deg, red 50%, white 50%) var(--_p, 100%) / 200%,
    linear-gradient(90deg, white 50%, red 50%) var(--_c, 0%) / 200% no-repeat;
  -webkit-background-clip: text, padding-box;
  background-clip: text, padding-box;
  transition: 0.4s;
}
.hover-4:hover {
  --_p: 50%;
  --_c: 50%;
  color: #0000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mask
&lt;/h3&gt;

&lt;p&gt;CSS Mask property makes two images overlap, where one image acts as a masking layer for another, thus clipping or removing the specific areas or parts of the secondary image. With the help of the Mask property, we can make an image work as a masking layer (alias luminance or alpha mask) for another image.&lt;/p&gt;

&lt;p&gt;Creating a masking layer is not just limited to images, any graphical element, such as linear gradients, can be transformed into a masking layer. Under the mask property, there comes a bunch of other properties. These properties include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;mask-clip&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-composite&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-image&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-mode&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-origin&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-position&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-repeat&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mask-side&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These properties come in handy to take over other important aspects of the mask effects like position, repeatedness, size, and side, etc. Now we will talk about the most frequently used properties of mask property.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mask-image
&lt;/h3&gt;

&lt;p&gt;The mask-image property allows us to make an image or any graphical element behave as a masking layer for another graphic element.&lt;/p&gt;

&lt;p&gt;Now let us see some working examples of Mask property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='image1'&amp;gt;
  &amp;lt;h3&amp;gt; Image 2&amp;lt;/h3&amp;gt;
  &amp;lt;img src='https://d33wubrfki0l68.cloudfront.net/d319533ac3d22c3186498254e0caee871796a29e/d7ce9/images/css/masking/image-mask.png' alt='img' height='210px'&amp;gt;
  &amp;lt;/div&amp;gt;

&amp;lt;div class='mask1'&amp;gt;
  &amp;lt;h3&amp;gt;Masked Image&amp;lt;/h3&amp;gt;
  &amp;lt;img src='https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg' alt='img'&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, you can observe that we have edited Image 1 to look like the pattern of Image 2. Let’s look at how mask property helped us achieve this effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mask-image:url(https://d33wubrfki0l68.cloudfront.net/d319533ac3d22c3186498254e0caee871796a29e/d7ce9/images/css/masking/image-mask.png);
    -webkit-mask-image:url(https://d33wubrfki0l68.cloudfront.net/d319533ac3d22c3186498254e0caee871796a29e/d7ce9/images/css/masking/image-mask.png);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can notice in the CSS styles that we have used the mask-image property to make Image 2 behave as a masking layer for Image 1, and the final result is displayed in the Masked Image.&lt;/p&gt;

&lt;p&gt;And if you think that the mask-image property is only limited to images. Then No! not just images; through mask properties, we can add many more effects to the image by using a wide range of graphical elements.&lt;/p&gt;

&lt;p&gt;Let’s see a few of them in action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='image1'&amp;gt;
  &amp;lt;h3&amp;gt;Original Image&amp;lt;/h3&amp;gt;
  &amp;lt;img src='https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg' alt='img'&amp;gt;
  &amp;lt;/div&amp;gt;

&amp;lt;div class='mask1'&amp;gt;
   &amp;lt;h3&amp;gt;Masked Image&amp;lt;/h3&amp;gt;
&amp;lt;img src='https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg'&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above snippet, we have added a dissolving effect to an image, giving the illusion that the upper part of the image is gradually dissolving in the white background. Here we have used the linear gradient as the graphical element in the mask-image property to add that dissolving effect.&lt;/p&gt;

&lt;p&gt;Similarly, you can imagine and create the image effect you want. You can take inspiration from some of the following fascinating image effects&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p class="codepen" data-height="300" data-default-tab="html,result" data-slug-hash="MWGvoqV" data-user="tsayush" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;"&amp;gt;
  &amp;lt;span&amp;gt;See the Pen &amp;lt;a href="https://codepen.io/tsayush/pen/MWGvoqV"&amp;gt;
  Untitled&amp;lt;/a&amp;gt; by Ayush Thakur (&amp;lt;a href="https://codepen.io/tsayush"&amp;gt;@tsayush&amp;lt;/a&amp;gt;)
  on &amp;lt;a href="https://codepen.io"&amp;gt;CodePen&amp;lt;/a&amp;gt;.&amp;lt;/span&amp;gt;
&amp;lt;/p&amp;gt;
&amp;lt;script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mask-position
&lt;/h3&gt;

&lt;p&gt;As the name defines, the mask-position property is used to assign the position of the masked graphical element. To set the position, you can use some predefined keywords with the mask-position property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mask-position: top;
mask-position: bottom;
mask-position: left;
mask-position: right;
mask-position: center;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mask-position property also supports the numeric values in percentage or size units for assigning the position of the masked element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mask-position: 20%;
mask-position: 50px;
mask-position: 10em 50em;
mask-position: 20% 60%;
mask-position: 10px 20em 30px 40em;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just like many other CSS styling properties, multiple values are also supported in the mask-position. In the case of 2 values, the first property is for the top and bottom positions, and the second value is for the left and right positions. In the case of 4 values, the values are for the top, right, bottom, and left positions, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/system-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;System testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, learn why System testing is important and all the intricacies of the System testing process.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Mask-size
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;mask-size&lt;/em&gt; property is used to specify the size of the masked graphical element. The mask-size property also comes with some predefined keywords to alter the size of the mask element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mask-size: cover;
mask-size: contain;
mask-size: auto;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Like the mask-position property, the mask-size property also supports multiple numeric values where the 1st value is for the width and the second is for the height.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mask-size: 12px;
mask-size: 30%;
mask-size: 20px 30px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s discuss how we can use the concepts of mask properties we have discussed till now to get some amazing animations with CSS hover effects. To better understand it, let’s create animation and analyze it side-by-side.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='mask1'&amp;gt;
  &amp;lt;img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can notice that in the image, we have designed some beautiful effects in the form of white translucent vertical strips. If you are getting confused about how all this works, don’t worry, we will, step-by-side, line-by-line, discuss how the mask properties acted as a helping hand to get this effect.&lt;/p&gt;

&lt;p&gt;The first step is to insert the image to add the animation over it. To give the user an incredible experience, we will add all the styling in the CSS hover pseudoclass. This will make the image look like an ordinary image at first, but as soon as the user moves the cursor over the image, beautiful animation comes into view, and the user experiences it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; -webkit-mask-image:
    linear-gradient(49deg, #000000 25%, rgba(0,0,0,0.2) 25%),
    linear-gradient(-49deg, #000000 25%, rgba(0,0,0,0.2) 25%),
    linear-gradient(49deg, rgba(0,0,0,0.2) 75%, #000000 75%),
    linear-gradient(-49deg, rgba(0,0,0,0.2) 75%, #000000 75%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first mask property we assign in the CSS styling is the mask-image property. As discussed in this CSS hover blog, the mask-image property adds effects over the image by making an image or graphical element behave as a masking layer. We have allocated linear-gradient styling to the mask-image property, and in that gradient, attributes have been fixed to generate the gradient effect on the image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-webkit-mask-size:30px 10px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next thing that comes is to assign the size of the mask effects. For that, we have initialized the mask-size property, which will manipulate the size of the linear gradient we have assigned in the mask-image property. The first attribute defined in the mask-size property is the width, and the second is the height.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-webkit-mask-position: 0 0, 0 10px, 10px -10px, -10px 0px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the only thing left to get the desired pattern is to assign the position to the mask-image property. To get the position, we used the mask-position property and set the position values for all four corners. For example, the first attribute of mask-position is the coordinates of the top-left corner; the second attribute is the coordinates of the top-right corner, and so on. And finally, after adding the mask-position property, we have got our desired pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
transition: all 2s ease-out;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To give it a beautiful touch, we have added the transition property, which will slow down the speed of the animation and give it a smooth look. Our beautiful image animation is ready.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class='container'&amp;gt;
  &amp;lt;img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" class='mask1'&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class='container'&amp;gt;
  &amp;lt;img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" class='mask2'&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class='container'&amp;gt;
  &amp;lt;img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" class='mask3'&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class='container'&amp;gt;
  &amp;lt;img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" class='mask4'&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above, we have attached a snippet containing some amazing image animations for you to take inspiration and create mind-blowing animations using your creativity.&lt;/p&gt;

&lt;p&gt;Adding animations with the help of mask property is not just limited to images; you can also generate text animations.&lt;/p&gt;

&lt;p&gt;Let’s create some text animations and understand if it’s working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h3 class="hover"&amp;gt;Hover Text&amp;lt;/h3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above snippet, we have designed a beautiful animation where the user hovers over the text, the color of the text gets changed, and an elegant pattern comes into view above, and below the text. Let’s understand how we created this animation.&lt;/p&gt;

&lt;p&gt;Firstly, we added the text through the heading tag and assigned some basic line height and padding CSS styling to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background:
          conic-gradient(from 180deg at top,red 45deg,#0000 0)
            left 0 bottom .15em/calc(2*.15em) .15em repeat-x,
          conic-gradient(from 85deg at top,#1095c1 50deg,#0000 0)
            left .15em bottom 0/calc(2*.15em) .15em repeat-x,        
           conic-gradient(from -45deg at bottom,red 45deg,#0000 0)
            left 0 top .15em/calc(2*.15em) .15em repeat-x,
          conic-gradient(from 45deg at bottom,#1095c1 145deg,#0000 0)
            left .15em top 0/calc(2*.15em) .15em repeat-x;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following that, we have assigned some gradient textures to the background. But to get the exact pattern shown in the final result, we have used the conical-gradient property. For both the above and below patterns, we have assigned different conic gradients alongside their respective attributes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-webkit-mask:
          linear-gradient(#000 0 0) content-box,
          linear-gradient(#000 0 0) 0/var(--_p,0%) padding-box no-repeat;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, to make the pattern visible, we first have to hide it. To hide the pattern, we have used the mask property, and the linear gradient property is used as an attribute. To target the particular areas to hide the pattern, content-box and padding-box attributes have been used in the linear gradient.&lt;/p&gt;

&lt;p&gt;In addition, we have created a CSS variable and used it in the size attribute of the linear gradient and kept its default value to 0%. This will keep the position of that gradient effect at 0%.&lt;/p&gt;

&lt;p&gt;Finally, we have added the CSS hover pseudoclass and assign the variable in it to the value of 100%. This will increase the value of p to 100%, increasing the gradient effect’s size and making the designed pattern visible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin:0 auto;
  cursor: pointer;
  padding: 0 .1em;
}

.hover-1 {
  line-height:1.1em;
  padding: calc(2.1*.15em);
  background:
    conic-gradient(from 180deg at top,red 45deg,#0000 0) 
      left 0 bottom .15em/calc(2*.15em) .15em repeat-x,
    conic-gradient(from 85deg at top,#1095c1 50deg,#0000 0) 
      left .15em bottom 0/calc(2*.15em) .15em repeat-x,

     conic-gradient(from -45deg at bottom,red 45deg,#0000 0) 
      left 0 top .15em/calc(2*.15em) .15em repeat-x,
    conic-gradient(from 45deg at bottom,#1095c1 145deg,#0000 0) 
      left .15em top 0/calc(2*.15em) .15em repeat-x;

    -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0) 0/var(--_p,0%) padding-box no-repeat;
  transition: .5s;
}
.hover-1:hover {
  --_p: 100%;
  color:#1095c1;
}

.hover-2{
    line-height:1.1em;
  padding: calc(2.1*.15em);
  background:
    linear-gradient(to top,red, red) 
      left 0 bottom .0em/calc(2*.01em) .05em repeat-x,
    linear-gradient(to top,#1095c1 ,#1095c1) 
      right .0em bottom 0%/calc(2*.03em) .05em repeat-y,

     linear-gradient(to top,red,red) 
      left 0 top .15em/calc(2*.03em) .15em repeat-y,
    linear-gradient(to top,#1095c1,#1095c1) 
      left .15em top 0%/calc(2*.15em) .05em repeat-x;

    -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0) 0/var(--_p,0%) padding-box no-repeat;
  transition: .5s;
}
.hover-2:hover {
  --_p: 100%;
  color:#1095c1;
}
.hover-3{
   line-height:1.1em;
  padding: calc(2.1*.15em);
  background:
    linear-gradient(to top,red, red) 
      left 0 var(--a, bottom) .0em/calc(2*.01em) .05em repeat-x,
    linear-gradient(to top,#1095c1 ,#1095c1) 
      var(--b, right) .0em bottom 0%/calc(2*.03em) .05em repeat-y,

     linear-gradient(to top,red,red) 
      var(--c, left) 0 top .15em/calc(2*.03em) .15em repeat-y,
    linear-gradient(to top,#1095c1,#1095c1) 
      left .15em var(--d, top) 0%/calc(2*.15em) .05em repeat-x;

    -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0) 0/var(--_p,100%) padding-box no-repeat;
  transition: .5s;
}
.hover-3:hover {
  --a: top;
  --b:left;
  --c: right;
  --d: bottom;
  --_p:100%;
  color:#1095c1;
}
.hover-4 {
  line-height:1.1em;
  padding: calc(2.1*.15em);
  background:
    linear-gradient(to top,red, red) 
      left 0 var(--a, bottom) var(--e, 0%)/calc(2*.01em) .05em repeat-x,
    linear-gradient(to top,#1095c1 ,#1095c1) 
      var(--b, right) var(--e, 0%) bottom 0%/calc(2*.03em) .05em repeat-y,

     linear-gradient(to top,red,red) 
      var(--c, left) var(--e, 0%) top .15em/calc(2*.03em) .15em repeat-y,
    linear-gradient(to top,#1095c1,#1095c1) 
      left .15em var(--d, top) var(--e, 0%)/calc(2*.15em) .05em repeat-x;

    -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0) 0/var(--_p,100%) padding-box no-repeat;
  transition: .5s;
}
.hover-4:hover {
  --a: top;
  --b:left;
  --c: right;
  --d: bottom;
  --e: 40%;
  --_p:100%;
  color:#1095c1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we know how to create some awesome text animations using mask property. Using the mask concepts we have discussed, you can design various text animations to add to your website. You can see the above example to get some text animation inspiration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/exploratory-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;Exploratory Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what Exploratory Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3D
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Until now, we have been discussing the animation happening in the 2D (2-Dimensional) plane. We looked at the background clipping property and mask property, explored its concepts, and created beautiful text and image animations using these properties. But now we will take it a step further.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let’s understand how we can create some real-life text animations or should I say, ‘3-D’ animations using CSS properties.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When it comes to 3D styling in CSS, the most frequently used CSS property is the transform property. The transform property allows us to perform various operations or actions on the elements. These operations can either be in the 2D plane or 3D. Below we have curated the operations available under the transform property:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rotate&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scale&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Skew&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Translate&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s understand each of them in a short introduction and their working.&lt;/p&gt;

&lt;h4&gt;
  
  
  Rotate
&lt;/h4&gt;

&lt;p&gt;As you can notice by the name, rotate property basically rotates the element with respect to the defined axis. If the user does not define any axis to rotate property, then by default, the rotate property rotates the element with respect to the initial position of the element.&lt;/p&gt;

&lt;p&gt;Let’s see a snippet of it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin: 0 auto;
  cursor: pointer;
  padding: 0 0.1em;
  color: #c689c6;
}
.rotate1 {
  transform: rotate(180deg);
}
.rotate2 {
  transform: rotateX(180deg);
}
.rotate3 {
  transform: rotateY(180deg);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this snippet, you can see the transformations in the text on providing different rotation attributes. For a better understanding, we have kept the degree of rotations the same in all cases so that the effect of different rotate properties could be easily seen and understood.&lt;/p&gt;

&lt;h4&gt;
  
  
  Scale
&lt;/h4&gt;

&lt;p&gt;Scale property changes the scale size or, in other words, changes the element size for the defined axis. We can increase or decrease the element size using the scale property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin:0 auto;
  cursor: pointer;
  padding: 0 .1em;
  color: #C689C6;
}

.scale1{
  transform:scale(2);
  padding-left:200px;
}

.scale2{
  transform:scaleX(2);
}

.scale3{
  transform:scaleY(2);
  padding-left:200px;
}
.scale4{
  transform:scale(0.5);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, in the attached snippet, you can observe that the scale of the element is changing depending upon the axis and scale value assigned to them. The scale increases if the value exceeds one and decreases for values less than 1.&lt;/p&gt;

&lt;p&gt;If the user does not assign any axis to the scale value, then by default, it takes both the axis and scales the element in the direction of both the x and y-axis.&lt;/p&gt;

&lt;h4&gt;
  
  
  Skew
&lt;/h4&gt;

&lt;p&gt;Skew property simply skews the element in the assigned axis to the assigned degree. Just like the previous two properties, the skew property can also be assigned in either x-axis or y-axis, or you can assign the box axis together by passing two values in the skew property where 1st value will represent the angle with the x-axis, and 2nd value represents y-axis angle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin: 0 auto;
  cursor: pointer;
  padding: 0 0.1em;
  color: #c689c6;
}
.skew1 {
  transform: skewX(20deg);
}
.skew2 {
  transform: skewY(20deg);
}
.skew3 {
  transform: skew(10deg, 10deg);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Translate
&lt;/h4&gt;

&lt;p&gt;Last but not the least, the translate property just translates the element in the defined axis. Rest all the working of the translate property is exactly the same as we have already discussed in the above properties.&lt;/p&gt;

&lt;p&gt;Now comes the example part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin:0 auto;
  cursor: pointer;
  padding: 0 .1em;
  color: #C689C6;
}

.translate1{
  transform:translateX(200px);
}
.translate2{
  transform:translateY(50px);
}

.translate3{
  transform:translate(200px, 50px);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let’s utilize what we have discussed so far about the transform property and create some beautiful animations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px 50px;
  place-content: center;
  align-items: end;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 4rem;
  margin:0 auto;
  cursor: pointer;
  padding: 0 .1em;}

  .transform{
  transform:skewX(var(--c,0deg)) scaleX(var(--d, 1));
    transition:all .3s ease-out;
}
.transform:hover{
  --c:30deg;
    color:#5C2E7E;
  --d:1.3;
  border: 2px solid red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above snippet, we have created a basic text animation where when the user hovers over the text, the text stretches along diagonally with the border of the text container.&lt;/p&gt;

&lt;p&gt;Let’s understand how it’s working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transform:skewX(var(--c,0deg)) scaleX(var(--d, 1));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get this type of animation, we have used the skew and scale properties of the transform property and assigned them to the x-axis and y-axis respectively. We have created two CSS variables when assigning values, keeping a default value for those variables. In CSS hover pseudoclass, different values have been given to these variables.&lt;/p&gt;

&lt;p&gt;This changes the variable values when the user hovers over the text, ultimately leading to an amazing animation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  display: grid;
  place-content: center;
}
img {
  width:40%;
  margin:0 auto;
  cursor: pointer;
}

  .transform{
  transform:skewX(var(--c,0deg)) scaleX(var(--d, 1));
    transition:all .3s ease-out;
}
.transform:hover{
  --c:30deg;
  --d:1.3;
  border: 4px solid black;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this same manner, you can add the transform animations to the images. Let’s create another text animation using the transform property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 20px;
  place-content: center;
  align-items: center;
}
h3 {
  font-family: system-ui, sans-serif;
  font-size: 6rem;
  margin:0;
  cursor: pointer;
  padding: 0 .1em;
   color: #1095c1;
  transition: all .5s ease-out;
}
.main:hover{
   text-shadow: 2px 1px 1px #56caf1,
        1px 2px 1px #56caf1,
        1px 3px 1px #56caf1,
        1px 4px 1px #56caf1,
        1px 5px 1px #56caf1,
        1px 6px 1px #56caf1,
        1px 7px 1px #56caf1,
        1px 8px 1px #56caf1,
        1px 9px 1px #56caf1,
        1px 10px 1px #56caf1,
    1px 18px 6px  rgba(86,202,241, 0.4),
    1px 22px 10px rgba(86,202,241, 0.2),
    1px 25px 35px rgba(86,202,241, 0.2),
    1px 30px 60px rgba(86,202,241, 0.4);
  transform:translateY(-30px);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we have created a 3D text animation where one of the users hovers the cursor over the text, the text floats upwards, and a slight shadow appears around the text. To create, we added the text and assigned some basic CSS styling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text-shadow: 2px 1px 1px #56caf1,
        1px 2px 1px #56caf1,
        1px 3px 1px #56caf1,
        1px 4px 1px #56caf1,
        1px 5px 1px #56caf1,
        1px 6px 1px #56caf1,
        1px 7px 1px #56caf1,
        1px 8px 1px #56caf1,
        1px 9px 1px #56caf1,
        1px 10px 1px #56caf1,
    1px 18px 6px    rgba(86,202,241, 0.4),
    1px 22px 10px rgba(86,202,241, 0.2),
    1px 25px 35px rgba(86,202,241, 0.2),
    1px 30px 60px rgba(86,202,241, 0.4);
  transform:translateY(-30px);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in the CSS hover pseudoclass, we added the text-shadow property and assigned it the dimensions of the shadow we want over the text.&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS Hover Effects on Mobile
&lt;/h3&gt;

&lt;p&gt;Till now, we have been talking about the CSS hover effects on desktop view. But things become slightly different when it comes to mobile views. On the desktop view, the visitor has the cursor, which (s)he can move over the animated element to witness the animation. But in the case of mobile view, the visitor does not have any cursor. Here, the finger touch does the work of the cursor. On mobile view, when the visitor touches the animated element, then the animation occurs.&lt;/p&gt;

&lt;p&gt;You may think that CSS hover animation could be added to the desired element for mobile view through &lt;a href="https://www.lambdatest.com/blog/css-media-queries-for-responsive-design/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_"&gt;css-media&lt;/a&gt;. You are correct, but there’s still a stumbling block left. When the visitor lifts his finger from the animated element, the element remains in its hover animation state. It kind of gets stuck to its animation state. The same problem occurs even when the user unintentionally taps on the animated element while scrolling or swiping through the screen.&lt;/p&gt;

&lt;p&gt;To solve this problem, W3C designed a bunch of new CSS styling properties, which could help the developers increase the code’s effectiveness by identifying the type of screen the user is using. The CSS styling properties include hover, any-hover, pointer, and any-pointer. Through these properties, the developer can identify the pointer type and type of screen the user is browsing on and then make the required changes to make the hover animation work perfectly.&lt;/p&gt;

&lt;p&gt;After assigning the CSS hover effects for different screen types, testing their responsiveness is crucial to check whether they work perfectly. This is where responsive testing tools like &lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;LT Browser&lt;/a&gt; comes in handy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;UI testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what UI testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to create a CSS Hover Effect Animation?
&lt;/h3&gt;

&lt;p&gt;A CSS hover animation arises when a user hovers their cursor over an element with CSS, and the element responds by moving or displaying another animated effect. Hover animations effectively increase the interactivity of your website by highlighting important elements on a page.&lt;/p&gt;

&lt;p&gt;CSS animation attributes are used to specify the series of animations that take place when an element hovers over to create a hover animation. The steps to create a basic CSS hover animation are as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Configure the animation property: Set the element’s initial CSS properties after defining it and specifying the element to which you wish to apply the hover animation. The element should then be given the &lt;code&gt;animation&lt;/code&gt; property, specifying the animation’s name, duration, timing function, delay, iteration count, direction, fill mode, and play state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specify the sub-properties for the animation property: You can define several sub-properties under the &lt;code&gt;animation&lt;/code&gt; property, including &lt;code&gt;animation-name&lt;/code&gt;, &lt;code&gt;animation-duration&lt;/code&gt;, &lt;code&gt;animation-timing-function&lt;/code&gt;, &lt;code&gt;animation-delay&lt;/code&gt;, &lt;code&gt;animation-iteration-count&lt;/code&gt;, &lt;code&gt;animation-direction&lt;/code&gt;, &lt;code&gt;animation-fill-mode&lt;/code&gt;, and &lt;code&gt;animation-play-state&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The CSS Hover Animation sequence should be defined using keyframes: You can specify the progression of an animation over time using keyframes. You can specify the CSS attributes to animate at different points in time by using the &lt;code&gt;@keyframes&lt;/code&gt; rule to generate a collection of keyframes for the animation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Utilize the CSS Hover Animation shorthand: You can condense all the sub-properties into a single line by using the &lt;code&gt;animation&lt;/code&gt; property’s shorthand version. Your code may become simpler and easy to comprehend as a result.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thus, defining the initial state of the element, specifying the animation attributes, defining the keyframes for the animation, and applying the animation to the element using the shorthand animation property are the steps in generating a CSS hover effect animation.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does LT Browser help you test the responsiveness of CSS Hover Effects?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/responsive-design"&gt;Responsive web design&lt;/a&gt; is the latest craze in web development. With Google specifying responsive design whenever possible and multiple devices flooding the market, responsive design has become a priority.&lt;/p&gt;

&lt;p&gt;Performing a &lt;a href="https://www.lambdatest.com/responsive-test-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;responsiveness test&lt;/a&gt; is a challenging job. You need various devices, and acquiring them is often challenging and costly. Instead, you should use an intelligent solution to let you conduct the test without buying different devices. That’s when the LT Browser becomes a savior.&lt;/p&gt;

&lt;p&gt;LT Brower is a complimentary tool offered by the LambdaTest platform. It is a &lt;a href="https://www.lambdatest.com/mobile-friendly-tester?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;mobile-friendly checker&lt;/a&gt; tool with 50+ pre-installed viewports for tablets, laptops, mobiles,and desktops. It helps you test websites across different viewports for Android, iOS, Windows, and macOS to check whether it works perfectly for every screen size.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Utqe_ZH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aj3rul8AQRBkvQiUT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Utqe_ZH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aj3rul8AQRBkvQiUT.png" alt="image" width="221" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To know more about LT Browser, watch the below tutorial&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/K1dlmU3QWWk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube"&gt;LambdaTest YouTube Channel&lt;/a&gt; and get the latest tutorial around &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;automation testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Selenium&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr19_"&gt;cypress&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping up
&lt;/h3&gt;

&lt;p&gt;In this guide, we learned how to use CSS hover effects from their implementation to a responsive test. I hope you enjoyed the article and found it helpful. If you have encountered any interesting experiences with hovers in CSS, please share them in the comment section below.&lt;/p&gt;

</description>
      <category>interactiveguide</category>
      <category>csshover</category>
      <category>css</category>
      <category>guide</category>
    </item>
    <item>
      <title>Creating A Cohesive User Experience Using HSL Colors In CSS</title>
      <dc:creator>ayush-tha</dc:creator>
      <pubDate>Tue, 18 Apr 2023 05:46:29 +0000</pubDate>
      <link>https://dev.to/ayushtha/creating-a-cohesive-user-experience-using-hsl-colors-in-css-mmc</link>
      <guid>https://dev.to/ayushtha/creating-a-cohesive-user-experience-using-hsl-colors-in-css-mmc</guid>
      <description>&lt;p&gt;We all know what importance colors hold in anything, whether it’s a website layout, image, video, or any other graphical element. In essence, color is a subjective experience that results from the interaction between light, the eye, and the brain. Adding colors to the website gives a new life to the whole layout and graphical elements. Nobody likes to visit web pages with white, black, and gray colors on them. Colors make the elements look more realistic and catchy to the human eye.&lt;/p&gt;

&lt;p&gt;Not just theoretically, Psychology also comes into play when we use colors on websites. It has been scientifically proven that a specific set of colors triggers particular emotions in the human brain, such as autumn colors like orange and yellow representing joy or happiness, red color to festive seasons, and blue viewed as calm and trustworthy. Besides, you must have noticed that many food companies often use red and yellow on their websites, pharmaceutical companies tend to use green on their sites, fitness companies sometimes use orange, and so on.&lt;/p&gt;

&lt;p&gt;Creating a user interface includes several things, including &lt;a href="https://www.lambdatest.com/blog/css-website-layouts/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS website layouts&lt;/a&gt;, elements, &lt;a href="https://www.lambdatest.com/blog/css-position-sticky-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS positioning&lt;/a&gt;, navigation, text, etc. Another thing that works as a factor for the user interface is the HSL Colors in CSS. CSS colors also hold importance in the user interface, which is one of the factors most people avoid.&lt;/p&gt;

&lt;p&gt;Not just website developers but professional photographers and video editors also use this game of colors a lot. Creating a perfect image is their job, and for that, they use color contrast a lot. Therefore, choosing the ideal set of colors for elements is highly important.&lt;/p&gt;

&lt;p&gt;CSS has many properties, including background-color, color, linear-gradient, etc., that let users add or fill the desired color to the elements. All these properties also help the users to make the font colorful or even add some beautiful color patterns to the texts and elements.&lt;/p&gt;

&lt;p&gt;All the CSS color properties require a color method to define the color and then fill that color in the specified element. CSS has some in-built color methods, such as HSL, RGB, HSLA, Hexadecimal, etc. Still, these color methods demand a collection of integer values in different units to retrieve the color.&lt;/p&gt;

&lt;p&gt;Though numerous blogs and tutorials focus on RGB and Hexadecimal methods, there is a need to cover the integral aspects of the HSL method. In this blog, we’ll dive deep into the role of HSL Colors in CSS, covering all nuances around the HSL method and how it differs from other methods.&lt;/p&gt;

&lt;p&gt;Before jumping straight to the HSL method, let’s discuss the other two CSS color methods — RGB and Hexadecimal, and why we need the HSL Colors in CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this tutorial, learn what is&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;&lt;strong&gt;&lt;em&gt;Regression testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its importance, types, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference Between RGB and Hex
&lt;/h3&gt;

&lt;p&gt;The RGB method works by considering that every color is a mixture of Red, Green, and Blue colors. This method demands three decimal values assigned within the range 0–255 in the function rgb(). These values specify the intensity level for each of the three colors, representing 0 value as the lowest intensity and 255 as the highest intensity.&lt;/p&gt;

&lt;p&gt;Here are some examples of RGB color combinations at different intensities:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Por5ZYMy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A7o9kyfzp2kjgsf8d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Por5ZYMy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A7o9kyfzp2kjgsf8d.png" alt="image" width="800" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s take an example to understand the working of the RGB method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  background-color: rgb(0, 200, 120);
  width: 100%;
  height: 100px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YFlxiHXV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A5SEpoa9dHR6I1orU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YFlxiHXV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A5SEpoa9dHR6I1orU.png" alt="image" width="800" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now coming to the Hexadecimal method. It also works on the concept that each color is a mixture of Red, Green, and Blue colors. The Hexadecimal method requires three two-digit HEX numbers and starts with a &lt;strong&gt;‘#’&lt;/strong&gt; sign. These three Hex values specify the intensity level of Red, Green, and Blue colors, respectively.&lt;/p&gt;

&lt;p&gt;Since there is the involvement of Hexadecimal values, and the Hexadecimal base comes in the range of 0–15 value, where values within the range of 10–15 are represented by alphabets A — F. Therefore, 00 gives the color with the lowest intensity and FF results in highest intensity level.&lt;/p&gt;

&lt;p&gt;Here are some common Hex colors with codes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KRbt_p02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AiB-aFNt9fxeKQLx9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KRbt_p02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AiB-aFNt9fxeKQLx9.png" alt="image" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s take an example to understand the working of the Hex method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1{
  background-color:#91D8E4;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pTpH-_Bi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AlH-7i0_K8f9Ekk9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTpH-_Bi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AlH-7i0_K8f9Ekk9k.png" alt="image" width="800" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Working with RGB and Hexadecimal methods is convenient and can give us everything we want. But that’s not true. Working with these two methods is not as easy as it seems. Let’s see how.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Experience the power of an&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;automation testing platform&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;with LambdaTest. Perform browser automation testing on the most powerful cloud infrastructure and leverage our platform for faster, reliable, and scalable automation testing in the cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Problems Associated with RGB and Hex Color Codes
&lt;/h3&gt;

&lt;p&gt;One of the significant problems these two methods bring is that they are not intuitive. That means they do not work on how a human brain recognizes colors. When a person sees a color, the human brain does not segregate that color into Red, Green, and Blue colors. Therefore, it becomes difficult for us to recognize the colors through their RGB number and Hexadecimal or decimal number.&lt;/p&gt;

&lt;p&gt;Among such difficulties, one instance in the daily life of developers or testers may arise is the need for &lt;a href="https://www.lambdatest.com/free-online-tools/convert-rgb-color-to-hex?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;RGB to Hex conversion&lt;/a&gt; or vice-versa for better human understanding and communication; here comes LambdaTest online free tools.&lt;/p&gt;

&lt;p&gt;When creating a user interface, UI designers and web developers need several shades of a particular color to maintain a constant theme throughout the interface. For example, 30 shades of blue, 20 shades of green, 10 shades of orange, etc., depending upon the requirement. It can create clutter if we use &lt;a href="https://www.lambdatest.com/blog/guide-to-css-variables-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog"&gt;CSS variables&lt;/a&gt; to hold these many variations of colors. When we notice that the RGB values of all these variations are unrelated, things worsen.&lt;/p&gt;

&lt;p&gt;But these disadvantages of RGB and Hexadecimal methods can be removed with the HSL Colors in CSS. Now let’s understand the role of HSL Colors in CSS by beginning the discussion with what the HSL method means, how it works, and how it overcomes the shortcomings of the RGB and Hexadecimal methods.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is HSL?
&lt;/h3&gt;

&lt;p&gt;HSL stands for Hue, Saturation, and Lightness. In other words, HSL is combined from three measurement factors — Hue, Saturation, and Lightness. Like the other two methods discussed above, the HSL method also works on the observation that each color is a mixture of Red, Green, and Blue colors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R0w9iQtg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ANiXuNeoaAtI3oLmP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R0w9iQtg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ANiXuNeoaAtI3oLmP.png" alt="image" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since the primary colors in the HSL format are Red, Green, and Blue, the RGB color wheel is the central concept behind the HSL Colors in CSS.&lt;/p&gt;

&lt;p&gt;The RGB (Red Green Blue) color wheel predominantly represents colors filled inside a circle. This wheel displays the relationship between primary, secondary, and tertiary colors. However, there are three types of color wheels — RGB (Red Green Blue), CMY (Cyan Magenta Yellow), and RYB (Red Yellow Blue).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YRYmHDvL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ALKXnHmxE0Lf0zsDi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YRYmHDvL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ALKXnHmxE0Lf0zsDi.png" alt="image" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Experience the benefits of&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;test automation cloud&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;with LambdaTest. Perform browser automation testing on the most powerful cloud infrastructure and leverage our platform for faster, reliable, and scalable test automation on the cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The above attached represents the RGB color wheel circle. You can observe that red is 0 degrees, green at 120 degrees, and blue at 240 degrees. Let’s dig deep into these three characteristics and understand what happens behind the scenes when we use the HSL Colors in CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hue&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Hue is the first value assigned in this method while using HSL Colors in CSS. It is the measure of the color’s angle on the color wheel. The defined angle value is calculated from the positive x-axis in the anti-clockwise direction, and the color at that angle is returned. Since it’s the measure of an angle, its default value is in degree units. But this method allows us to define angle values in other units, including rad, grad, and turn.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S17Jl9w6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A0tjCf4e_fu5qkwq_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S17Jl9w6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A0tjCf4e_fu5qkwq_.png" alt="image" width="800" height="799"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The value of the angle unit comes within a range of 0–360 degrees. Red at 0 degrees, green at 120 120 degrees, and blue at 240 degrees. For rad, the range of values is 0–6.28 rad. The most commonly used unit values in the HSL Colors in CSS are the degree values.&lt;/p&gt;

&lt;p&gt;Let’s take an example to understand the working of Hue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div {
  border: 2px solid;
  height: 100px;
  background-color: hsl(123deg, 39%, 49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rkY9hv-v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A5uD_D4ITGEpDs3sM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rkY9hv-v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A5uD_D4ITGEpDs3sM.png" alt="image" width="800" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Although the angle values are restricted between 0–360, it can accept values less than 0 degrees and greater than 360 degrees. When the value is above 360, it gets converted to the value in the range by subtracting it from 360. In the case of values less than 0 or negative values, the value is added to 360, and the resultant value is then used to retrieve color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; background-color: hsl(400deg, 39%, 49%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2wWfbYPX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A_gtwqXwbW7qUl-kV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2wWfbYPX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A_gtwqXwbW7qUl-kV.png" alt="image" width="800" height="98"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background-color: hsl(-120deg, 39%, 49%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G4hi_Jmz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AiwwJzovgxBJzYDQw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G4hi_Jmz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AiwwJzovgxBJzYDQw.png" alt="image" width="800" height="94"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container1"&amp;gt;Container 1&amp;lt;/div&amp;gt;
&amp;lt;div class="container2"&amp;gt;Container 2&amp;lt;/div&amp;gt;
div {
  border: 2px solid;
  height: 100px;
  text-align: center;
  font-size: 80px;
  margin-bottom: 10px;
}


.container1 {
  background-color: hsl(60, 39%, 49%);
}


.container2 {
  background-color: hsl(420, 39%, 49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZfM_ONQb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ADC-XaU0_a1Gtmnbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZfM_ONQb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ADC-XaU0_a1Gtmnbe.png" alt="image" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we consider in terms of angular values, then 60 deg and 420 deg (420–360 = 60) both values are the same. Therefore, we are getting the same background color in both containers, as observed in the above example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  background-color: hsl(90, 39%, 49%);
}


.container2 {
  background-color: hsl(-270, 39%, 49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cXassvrr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AaE9ok2C96HmIMT5R.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cXassvrr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AaE9ok2C96HmIMT5R.png" alt="image" width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here also, you can observe that 90 deg and -270 deg give us the same result because of the same reason in the previous example. 90 deg and -270 deg, both the values are the same if we take them in the angular values.&lt;/p&gt;

&lt;p&gt;Now, let’s move on to the 2nd characteristic of the HSL method, i.e., Saturation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Saturation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Saturation defines the purity level of the color and how much the color will be saturated or unsaturated. In other words, the saturation characteristic manipulated the intensity level of the color. The saturation measure accepts an integer value in percentage units to define the saturation of the color.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x0aVwi2L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A1DF6W2NEH6wOr4qF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x0aVwi2L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A1DF6W2NEH6wOr4qF.png" alt="image" width="496" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s take an example to understand the working of Saturation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
  background-color:hsl(60, 45%,49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wvJHBgqt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aqq1woT0f4gBtzEJ5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wvJHBgqt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aqq1woT0f4gBtzEJ5.png" alt="image" width="800" height="96"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the value of the saturation characteristic is high, then the color intensity is also high, and the amount of gray shade in that color will be less. Therefore, a 100% value of the saturation will give us pure color, a 50% value will result in half color and half gray shade, and 0% will result in the complete gray shade.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1{
  background-color:hsl(60, 0%,49%);
}


.container2{
  background-color:hsl(420, 25%,49%);
}


.container3{
  background-color:hsl(420, 50%,49%);
}


.container4{
  background-color:hsl(420, 75%,49%);
}


.container5{
  background-color:hsl(420, 100%,49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k9soASmG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AcqEYgqiG2nBoGqrw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k9soASmG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AcqEYgqiG2nBoGqrw.png" alt="image" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, you can see the difference we are getting in the background color of the containers on increasing the value of saturation characteristic from 0% — 100%. On 0% value, we are getting the full gray color in container 1, and as the value increases, the color’s intensity also increases. At last, the intensity is highest at 100% in container 5.&lt;/p&gt;

&lt;p&gt;Since the saturation characteristic accepts a percentage value, the obtained value falls under the 0% — 100% range. Somehow, the user can also pass values greater than 100% and less than 0% in the saturation characteristic.&lt;/p&gt;

&lt;p&gt;But just like the Hue characteristic, there’s no use in passing values out of the limit because if the user passes a value greater than 100%, the intensity of the color remains equal to 100%. On values below 0% (negative values), the intensity remains equal to 0%.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;Selenium online&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Automation Testing scripts on the LambdaTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments. Try it for free.&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  background-color: hsl(60, 0%, 49%);
}


.container2 {
  background-color: hsl(420, -25%, 49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jQ6sXABh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AvG4fxlu41lPBU8V8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jQ6sXABh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AvG4fxlu41lPBU8V8.png" alt="image" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can observe that we have assigned values 0% and -25% for the saturation characteristic, and in both the containers, we are getting the same background color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  background-color: hsl(60, 100%, 49%);
}


.container2 {
  background-color: hsl(420, 200%, 49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bRrAZ32U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AyziEI9YftNwOUNgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bRrAZ32U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AyziEI9YftNwOUNgi.png" alt="image" width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, we have initialized the value 100% and 200% for the saturation characteristic, and for these two different values, we are getting the same background color in both containers.&lt;/p&gt;

&lt;p&gt;Now, the time is for the final characteristic of the HSL method used in HSL Colors in CSS, i.e., Lightness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lightness&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As the name suggests, the Lightness characteristic controls the amount of light in color. In order words, lightness can also be described as the property that controls how much that color will be, light or dark. Like the saturation characteristic, the lightness characteristic also demands an integer value in percentage units.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--157aFmeg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Ail53N2KKuHkzl3o9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--157aFmeg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Ail53N2KKuHkzl3o9.png" alt="image" width="554" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s consider an example to understand the working of Lightness.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  background-color: hsl(60, 39%, 49%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Igce1MRU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AkbsDLi_mo2WdNhGA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Igce1MRU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AkbsDLi_mo2WdNhGA.png" alt="image" width="800" height="93"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  background-color: hsl(60, 39%, 0%);
  color: white;
}


.container2 {
  background-color: hsl(420, 39%, 25%);
}
.container3 {
  background-color: hsl(420, 39%, 50%);
}
.container4 {
  background-color: hsl(420, 39%, 75%);
}
.container5 {
  background-color: hsl(420, 39%, 100%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n44Gpb3o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AtmdKUf9i4MoebPcs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n44Gpb3o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AtmdKUf9i4MoebPcs.png" alt="image" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can observe that at 0% lightness, the background color is pitch black in Container 1, and as the value of lightness is increasing, the lightness in color increases, and at 100% lightness is full; therefore, the background color is full white in the Container 5.&lt;/p&gt;

&lt;p&gt;Like the saturation characteristic, the lightness characteristic accepts values above 100% and below 0%. But values above 100% work the same as 100%, and values below 0% (negative values) work the same as 0%. Let’s see this in action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  background-color: hsl(60, 39%, 0%);
}


.container2 {
  background-color: hsl(420, 39%, -25%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TofG3LPQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Av12-iMZpBer240mJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TofG3LPQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Av12-iMZpBer240mJ.png" alt="image" width="800" height="188"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  background-color: hsl(60, 39%, 100%);
}


.container2 {
  background-color: hsl(420, 39%, 250%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3IcxXuxc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AfLECLxtiq9SdC5j9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3IcxXuxc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AfLECLxtiq9SdC5j9.png" alt="image" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, you can observe that although we have assigned a 100% lightness value in Container 1 and a 200% value in Container 2, it still gives us the same result in the background color.&lt;/p&gt;

&lt;p&gt;We have been discussing the three characteristics of HSL Colors in CSS, but that’s not all. Another feature under HSL Colors in CSS is “A,” short for “alpha.” It’s the 4th characteristic. Alpha characteristic specifies the opacity of the color. In other words, the alpha characteristic simply adjusts the transparency level of the color. In HSL, to use alpha characteristics, the HSLA method is used.&lt;/p&gt;

&lt;p&gt;Unlike other characteristics of the HSL Colors in CSS, which require a value consisting of units, the alpha characteristic does not require a unit value. Alpha characteristic demands a unitless value ranging from 0–1. At 0, the color is invisible or hidden; at 1, the alpha characteristic is at its peak, and the color is totally visible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
  background-color:hsla(60, 39%,49%, 0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kFuigEld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A0dIU74U0-vj9jM8R.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kFuigEld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A0dIU74U0-vj9jM8R.png" alt="image" width="800" height="95"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
  background-color:hsla(60, 39%,49%, 1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q0hXvsPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AOKW0eWnh8usvC-Cb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q0hXvsPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AOKW0eWnh8usvC-Cb.png" alt="image" width="800" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, as we have assigned the alpha characteristic with value 1, the background color of the container comes into appearance, and we can start the background color.&lt;/p&gt;

&lt;p&gt;Demanding a unitless value is not the only thing that differentiates alpha characteristics. An alpha characteristic can accept any value between 0 to 1, even the decimal values (0.1, 0.2, 0.01), which does not work in the other characteristic of the HSL Colors in CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  background-color: hsla(60, 39%, 49%, 0.5);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cdqxYU52--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ANeHCLjVNLVXXIGC-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cdqxYU52--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ANeHCLjVNLVXXIGC-.png" alt="image" width="800" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, as you can observe, we have assigned 0.5 (half) value to the alpha characteristic. Therefore, as a result, we are getting the background color with half transparency in the container. Not just one-place decimals, alpha characteristics also accept 2 place decimals. This gives full control over the transparency level of the color.&lt;/p&gt;

&lt;p&gt;Here’s an example showing it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  background-color: hsla(60, 39%, 49%, 0.25);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gljoGhpV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aag6ijSg5Z2EMskzh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gljoGhpV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aag6ijSg5Z2EMskzh.png" alt="image" width="800" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we have passed a 0.25 value which is a two-place decimal value to the alpha characteristic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;Selenium Automation Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;scripts on the LambdaTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments. Try it for free.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of using HSL Colors in CSS
&lt;/h3&gt;

&lt;p&gt;HSL (Hue, Saturation, Lightness) colors are a relatively new addition to the CSS color module, offering a more intuitive and flexible way to specify colors in web development. Compared to traditional RGB or Hexadecimal color codes, HSL Colors in CSS provide a range of advantages for designers and developers.&lt;/p&gt;

&lt;p&gt;In this section, we will explore the benefits of using HSL colors in CSS in more detail and discuss how they can be used to create visually appealing and accessible designs for web pages and applications.&lt;/p&gt;

&lt;p&gt;Regarding practical application, the HSL Colors in CSS are considered at many professional levels for usage because of their advantages.&lt;/p&gt;

&lt;p&gt;There are several advantages of using HSL Colors as listed below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Improves the overall workflow by making it much smoother.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extremely useful when we used to get different colors by keeping the standard base color.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A powerful and straightforward method that offers a vast possibility of colors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works on the practical way people observe colors and is easy to learn and read fast.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Colors generated by the HSL method are clearly expressed, and one can easily imagine the result.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another significant advantage of using HSL Colors in CSS is that it also works as an alternative to the RGB and can be easily converted into RGB. Since both the RGB and HSL method demands a collection of numerical values to work, we can take advantage of methods that can easily convert the numerical values of the HSL Colors to the fraction values for the RGB method.&lt;/p&gt;

&lt;p&gt;To make things even easier, several online color converters can convert color methods from one to another. All these advantages make the HSL Colors in CSS a preferred method to define colors in projects. And there are many more reasons why the number of developers who choose to use the HSL Colors in CSS over others is increasing daily. Although most CSS experts still prefer to use HEX or RGB methods over HSL, HSL is gaining attention day by day.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applications of Using HSL Colors in CSS
&lt;/h3&gt;

&lt;p&gt;HSL colors in CSS provide a versatile and intuitive way to specify colors and have numerous applications in web development. Here are some of the key applications of using HSL colors in CSS:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tinted Colors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At a professional level, to create a constant theme throughout the interface, the website theme is designed by using different shades of a particular color at the different sections of the interface. The HSL method becomes very handy in such scenarios.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IU7Kuh4m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aut14lHtbsUzCsYDU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IU7Kuh4m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Aut14lHtbsUzCsYDU.png" alt="image" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, we have considered two basic website layouts. In both of these, the header section is filled with a background color, and the content section has the same background color but a much lighter shade. To get this effect, we have kept the lightness characteristic value low in the header section and high in the content section.&lt;/p&gt;

&lt;p&gt;By experimenting with the lightness characteristic at different values, we can get dark and light shades of the same color to use in the website themes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dark shade colors on Hover&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You may have witnessed that some elements in the website’s interface change color when the user hovers over it. Their color gets changed from lighter shade to darker shade. In this place, HSL Colors in CSS comes into play to give the lighter and darker shades of a common color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button {
  padding: 10px;
  border-radius: 20px;
  background-color: hsl(240, 39%, 70%);
  color: white;
  font-size: 20px;
}


button:hover {
  background-color: hsl(240, 39%, 50%);
  cursor: pointer;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mFHaXSmn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A1XAEQlE2rSlrnniF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mFHaXSmn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A1XAEQlE2rSlrnniF.png" alt="image" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can observe that in the upper button, the color is of light shade, for that, we have kept the value of lightness characteristics at 70%. And after the hover, the button color gets changed to a darker shade, as you can notice in the below button. To get this effect, we have assigned a value of 50% to the lightness characteristic, which is lower than the upper button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shades of White color&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most of the time, we need to use white as the font color to make the text look slightly different from the overall website interface. But using the same white shade for every text dulls the user experience. To avoid this, we can use different shades of white to make the text stand out and keep it interesting.&lt;/p&gt;

&lt;p&gt;The HSL Colors in CSS can help us to get different shades of white color. We can add different values to the lightness characteristic in the HSL method to get the different shades of white color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container1 {
  color: hsl(30, 49%, 100%);
}


.container2 {
  color: hsl(30, 49%, 90%);
}


.container3 {
  color: hsl(30, 49%, 95%);
}


.container4 {
  color: hsl(30, 49%, 85%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ewwp1mA1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ArqeAWaXVCXmrbXfb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ewwp1mA1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2ArqeAWaXVCXmrbXfb.png" alt="image" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, you can observe that in all four containers, the text is not the basic white color. We have used different shades of white to give it an exciting look and keep it white. For that, we manipulated the lightness characteristics value for the font color.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Button Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The HSL Colors in CSS also come in very handy when we have two different shades of the same color for buttons. Assigning different shades of a common color makes it easy for the user to quickly identify which is the primary and which is the secondary button.&lt;/p&gt;

&lt;p&gt;In real life, dark shade colors are used for the primary buttons, and shade colors are used for the secondary colors. To get the light and dark shades of a common color, we pass high and low values to the lightness characteristic in the HSL method.&lt;/p&gt;

&lt;p&gt;Let’s see this in action by considering an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.primary {
  color: white;
  background-color: hsl(10, 49%, 55%);
}


.secondary {
  background-color: hsl(10, 49%, 80%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2aUw38PJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A6JcvMsreF1jFJkw3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2aUw38PJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2A6JcvMsreF1jFJkw3.png" alt="image" width="340" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, the upper button is the primary one, and the lower button is the secondary one. The dark shade color is used in the primary button with a low lightness value, and the light shade color is used in the secondary button with a high lightness value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dark Theme colors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using correct color contrast is essential in the user interface. Especially when the user has enabled the dark theme on the website. According to studies done in 2022, 81.9% of users use the dark theme on their smartphones. From this, you can imagine the importance of color contrast in dark theme user interfaces.&lt;/p&gt;

&lt;p&gt;As per the WCAG’s accessibility standard, at least 4:5:1 for body text against dark surfaces should be maintained. And to obey this rule, the use of saturated colors is avoided in dark themes. Using saturated colors also increases eye strain if used with a dark background.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xc72FQMD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Angiuoy63MMYQ6i4p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xc72FQMD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2Angiuoy63MMYQ6i4p.png" alt="image" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above figure, it is obvious that it’s much easier to read text with a low saturation value than text with a high saturation value. Therefore, it’s always suggested to use unsaturated colors against dark-colored backgrounds.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Choose the Best Color Specifier?
&lt;/h3&gt;

&lt;p&gt;The three methods we have discussed have their advantages and disadvantages. It depends upon the use case which color specifier performs best for it. There is no common factor on which we can compare all three color specifiers, but let’s examine each of these.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hexadecimal&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are not into any field of designing and creating projects for personal use, then you might have to use a hexadecimal method to specify colors. Many developers prefer the Hexadecimal method because of its simplicity, which does not include too much complexity, unlike RGB and HSL Colors in CSS.&lt;/p&gt;

&lt;p&gt;Copy the hex code of your desired color and embed it in your program. But challenges arise when we need to manipulate the opacity of the color. The Hexadecimal method does not give the users control of color opacity.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;RGB&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now When to choose the RGB method. This method is handy for all professional developers and designers in the photo editing and designing field. Another reason is that the RGB method is the most commonly used color specifier in many popular designing software, including CorelDraw, PhotoShop, and Illustrator. But the RGB method fails when it comes to offering different shades of the same color without getting too complex.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HSL&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now consider the HSL method. Professional web developers and user interface designers tend to maintain a common theme throughout the interface. In this situation, using the HSL Colors in CSS becomes a helping hand because of its ability to alter the shade of color by changing the values of saturation and lightness characteristics. In the end, it all comes down to individual preference. You can choose any of these three specifiers to carry out your work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Automate&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;&lt;strong&gt;&lt;em&gt;Cypress testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and perform browser automation testing with LambdaTest. Our cloud infrastructure has 3000+ desktop &amp;amp; mobile environments. Try for free.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Browser Compatibility
&lt;/h3&gt;

&lt;p&gt;There is no use in specifying colors if the defined colors do not give the desired output on browsers. To avoid such a situation, the color specifier used in designing the user interface should be compatible with every browser.&lt;/p&gt;

&lt;p&gt;Fortunately, the working of the HSL Colors in CSS is entirely independent of the browser. The HSL method is fully browser compatible. So, no matter what browser the user uses, he will always land on the webpage having properly defined colors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vA_KCarO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AMCEIaD-EJma8IIqz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vA_KCarO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/0%2AMCEIaD-EJma8IIqz.png" alt="image" width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, you can perform &lt;a href="https://www.lambdatest.com/cross-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;cross browser testing&lt;/a&gt; to ensure the HSL Colors in CSS gives the desired result on every browser. A bunch of continuous quality testing platforms like LambdaTest helps you run &lt;a href="https://www.lambdatest.com/learning-hub/cross-browser-compatibility?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub"&gt;cross browser compatibility testing&lt;/a&gt; across different real browsers, devices, and OS combinations. It checks whether the specified CSS colors work correctly in browsers and devices.&lt;/p&gt;

&lt;p&gt;Watch this below tutorial to learn how to perform live-interactive testing of your websites using the LambdaTest platform.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WYbyLfLM2-E"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can also subscribe to our &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube"&gt;LambdaTest YouTube Channel&lt;/a&gt; to learn about automation tools like &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Selenium&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Playwright&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr18_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage"&gt;Appium&lt;/a&gt;, and many more tutorials around testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping Up!
&lt;/h3&gt;

&lt;p&gt;This blog taught us about the role of HSL Colors in CSS and how they differ from other color methods. We also discussed the applications of HSL Colors in CSS and their benefits. We’ve also learned how HSL Colors in CSS provide greater flexibility and precision when specifying colors in web design.&lt;/p&gt;

&lt;p&gt;By using HSL Colors in CSS, designers can have more control over the saturation and lightness of colors, resulting in a broader range of hues and shades available for use in websites and applications to match a brand’s identity or aesthetic vision.&lt;/p&gt;

&lt;p&gt;HSL Colors in CSS allow more accessibility to people having special abilities; by simply adjusting the lightness and saturation of colors, creating more contrast and legibility for text and other design elements, making it easier for users to navigate and understand the content. Overall, the HSL colors in CSS provide a powerful tool for web designers and developers to create vibrant and accessible color schemes in their web designs.&lt;/p&gt;

&lt;p&gt;I appreciate you taking the time to read this article all the way through. If you have any questions, please comment below, and I’ll be happy to respond.&lt;/p&gt;

&lt;p&gt;Happy Testing!❤️&lt;/p&gt;

&lt;h1&gt;
  
  
  LambdaTestYourApps
&lt;/h1&gt;

</description>
      <category>css</category>
      <category>csscolor</category>
      <category>hsl</category>
      <category>userexperience</category>
    </item>
  </channel>
</rss>
