<?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>Forem:  Alex Anie</title>
    <description>The latest articles on Forem by  Alex Anie (@alexanie).</description>
    <link>https://forem.com/alexanie</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%2F992878%2F946cd5ec-806b-4f8e-8340-33e4449226d3.png</url>
      <title>Forem:  Alex Anie</title>
      <link>https://forem.com/alexanie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/alexanie"/>
    <language>en</language>
    <item>
      <title>How to Handle Dropdowns Using the Cypress .select() Command</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Tue, 03 Jun 2025 14:49:50 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-handle-dropdowns-using-the-cypress-select-command-4d4i</link>
      <guid>https://forem.com/testmuai/how-to-handle-dropdowns-using-the-cypress-select-command-4d4i</guid>
      <description>&lt;p&gt;Dropdowns can be challenging to handle due to dynamic options, inconsistent values, or differences between displayed text. In Cypress, you can overcome this challenge using the .select() command.&lt;/p&gt;

&lt;p&gt;It allows you to handle (or select) dropdowns by visible text, value, or index. The Cypress .select() command is a built-in function that interacts with and performs tests on the selected elements in a web application.&lt;/p&gt;

&lt;p&gt;In this blog, you will learn everything you need to know about using the Cypress .select() command.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Cypress .select() Command?
&lt;/h2&gt;

&lt;p&gt;The Cypress .select() command is a built-in function that is used to select a  tag within the  WebElement. It retrieves the selected  tags and performs tests on them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.select(value)
.select(values)
.select(value, options)
.select(values, options)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Cypress &lt;em&gt;.select()&lt;/em&gt; command takes in two arguments, the first being value, which can be any of the following; &lt;em&gt;value, index, or text content of the  tag.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The second argument is optional but can be specified as a configuration object. For example, &lt;em&gt;(force: true)&lt;/em&gt; can be used to undo the default behavior of the &lt;em&gt;.select()&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;select&amp;gt;
 &amp;lt;option value="one"&amp;gt;apples&amp;lt;/option&amp;gt;
 &amp;lt;option value="two"&amp;gt;oranges&amp;lt;/option&amp;gt;
 &amp;lt;option value="three"&amp;gt;bananas&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript:&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;cy.get('select').select(0).should('have.value', 'one')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we get the &lt;em&gt;&lt;/em&gt; WebElement and pass in an integer with a value of zero; then, we assert that the selected WebElement should have a value of “one” as a means of validation before test execution.&lt;/p&gt;

&lt;p&gt;The Cypress &lt;em&gt;.select()&lt;/em&gt; command is used to handle both types of dropdowns: static and dynamic.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Handle Static Dropdowns?
&lt;/h2&gt;

&lt;p&gt;Static dropdowns are a type of select control in which the selection content is loaded in the browser as soon as the page loads. They are usually hard-coded into the HTML of the web page.&lt;/p&gt;

&lt;p&gt;There are different ways to select static dropdown options using the Cypress .select() command, including selecting by index, value, or text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Select by Index
&lt;/h3&gt;

&lt;p&gt;Select by index is one of the methods that can be used to select  tag within the  element. The index refers to an integer that represents the number of  tags within the parent  element. The first element is identified as 0, and then the second as 1, and so on.&lt;/p&gt;

&lt;p&gt;To see this in action, let’s use the LambdaTest eCommerce Playground.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the LambdaTest eCommerce Playground on your web browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Press the Tab with F12 on your keyboard to launch the DevTools.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#entry_212434 #input-sort-212434
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the above CSS selector and press CTRL + F. Then, paste the CSS selector in the find box indicated by the red box.&lt;/p&gt;

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

&lt;p&gt;This should target and select the right WebElement as highlighted in the yellow color below:&lt;/p&gt;

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

&lt;p&gt;After identifying the selected element, run the Cypress test script below to execute the test case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Select the index', () =&amp;gt; {
    it('select the option tag with an of 1', () =&amp;gt; {
      cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=product/manufacturer/info&amp;amp;manufacturer_id=9')
      cy.get('#entry_212434 #input-sort-212434').select(1)

    // Wait for the page to update or stabilize
    cy.url().should('include', 'sort=order_quantity')

    // Assert the selected option's text is 'Best sellers'
    cy.get('#entry_212434 #input-sort-212434 option:selected')
      .should('have.text', 'Best sellers')
    })
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Your test run should be indicated as shown below:&lt;/p&gt;

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

&lt;p&gt;In the image above, the Best Sellers option is selected in the select control.&lt;/p&gt;

&lt;h3&gt;
  
  
  Select by Value
&lt;/h3&gt;

&lt;p&gt;Selecting a dropdown by value is very similar to selecting an element by index. Instead of passing integers as value to the &lt;em&gt;.select()&lt;/em&gt; command, the value property of the &lt;em&gt;&lt;/em&gt; tag is used instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Select web element by value', () =&amp;gt; {
    it('Select the option element by the value attribute', () =&amp;gt; {
      cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=product/manufacturer/info&amp;amp;manufacturer_id=9')
      cy.get('#entry_212434 #input-sort-212434')
      .select('https://ecommerce-playground.lambdatest.io/index.php?route=product/manufacturer/info&amp;amp;manufacturer_id=9&amp;amp;sort=p.viewed&amp;amp;order=DESC')
    })
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above used the &lt;em&gt;.select()&lt;/em&gt; command to interact with the &lt;em&gt;&lt;/em&gt; WebElement and retrieve the &lt;em&gt;&lt;/em&gt; tag with the value &lt;em&gt;Popular&lt;/em&gt; text.&lt;/p&gt;

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

&lt;p&gt;Here, the &lt;em&gt;&lt;/em&gt; WebElement uses the &lt;em&gt;value&lt;/em&gt; to choose the &lt;em&gt;Popular option&lt;/em&gt;, which corresponds to the text displayed in the dropdown. The test simulates selecting the most popular items on the Canon product list by interacting with the dropdown element.&lt;/p&gt;

&lt;h3&gt;
  
  
  Select by Text
&lt;/h3&gt;

&lt;p&gt;To select an element by text, the &lt;em&gt;.select()&lt;/em&gt; command received the text content as an argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Select web element by Text', () =&amp;gt; {
    it('Select the option tag with a Newest', () =&amp;gt; {
      cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=product/manufacturer/info&amp;amp;manufacturer_id=9')
      cy.get('#entry_212434 #input-sort-212434')
      .select('Newest')
    })
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the text content of the &lt;em&gt;&lt;/em&gt; element Newest is passed to the &lt;em&gt;.select()&lt;/em&gt; command. This allows Cypress to retrieve the WebElement associated with &lt;em&gt;Newest&lt;/em&gt; and then perform a test on it.&lt;/p&gt;

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

&lt;p&gt;From the image above, the select control selected the &lt;em&gt;&lt;/em&gt; element with the text content of the &lt;em&gt;Newest&lt;/em&gt; element.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Handle Dynamic Dropdowns?
&lt;/h2&gt;

&lt;p&gt;Dynamic dropdowns are selection controls in which the options are rendered dynamically depending on the content or user search input.&lt;/p&gt;

&lt;p&gt;Initially, the _ _elements are not present when the page first loads. Instead, the dropdown waits for the user’s input or an event to trigger before it loads the options dynamically into the page.&lt;/p&gt;

&lt;p&gt;Cypress sends requests by passing text into the input control. It then waits for the content to load on the page before interacting with it.&lt;/p&gt;

&lt;p&gt;To handle dynamic dropdowns in Cypress, you can use &lt;em&gt;.contains()&lt;/em&gt; and &lt;em&gt;.each()&lt;/em&gt; commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  .contains() Command
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;.contains()&lt;/em&gt; command in Cypress retrieves the DOM element containing the text passed in. It can take more than one argument.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&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;.contains(content)
.contains(content, options)
.contains(selector, content)
.contains(selector, content, options)

// getting web elements that contain
cy.contains(content)
cy.contains(content, options)
cy.contains(selector, content)
cy.contains(selector, content, options)

// usage
cy.get('.nav').contains('About') 
cy.contains('Hello')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To demonstrate, we will leverage the Cypress &lt;em&gt;.contains()&lt;/em&gt; command to dynamically interact with dropdowns on a web page.&lt;/p&gt;

&lt;p&gt;We will use the LambdaTest eCommerce Playground. When a user inputs “iPhone” into the navigation search bar, a list of matching product items is displayed as clickable links within the dropdown.&lt;/p&gt;

&lt;p&gt;The Cypress &lt;em&gt;.contains()&lt;/em&gt; command is used to assert that the search query is present within the returned product list and, if found, triggers a click action on the corresponding item. This approach is particularly useful for automating the testing of dynamic dropdowns and validating that search functionality behaves as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  describe('Dynamic Dropdown Test', () =&amp;gt; {
    it('should select a specific option from a dynamically loaded dropdown', () =&amp;gt; {
      // Step 1: Visit the page  cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=common/home');  // Replace with your actual page URL

      // Step 2: Click on the dropdown to trigger the loading of dynamic options
      cy.get('#entry_217822 &amp;gt; div input[placeholder="Search For Products"]').click();  // Adjust selector for the dropdown

      // Step 3: Wait for the dropdown options to be visible (if required)
      cy.get('#entry_217822 &amp;gt; div input[placeholder="Search For Products"]') // Selector for the dropdown options container
        .should('be.visible');

      // Step 4: Optionally filter options by typing in the dropdown's input field
      cy.get('#entry_217822 &amp;gt; div input[placeholder="Search For Products"]').type('iPod Touch'); // Adjust if needed for input

      // Step 5: Select an option dynamically
      cy.contains('#search &amp;gt; div.search-input-group.flex-fill &amp;gt; div.dropdown &amp;gt; ul li', 'iPod Touch') // Adjust selector for dropdown item
        .click();

      // Step 6: Assert that the correct option is selected
      cy.get('#entry_217822 &amp;gt; div input[placeholder="Search For Products"]').should('have.value', 'iPod Touch');
    });
  });
&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://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wpkdx0qrbagsvmi4kth.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wpkdx0qrbagsvmi4kth.png" alt=" " width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  .each() Command
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;.each()&lt;/em&gt; command in the dynamic dropdown iterates through the elements that match the specified text and provides an interface to interact with the selected WebElement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&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;cy.get('ul&amp;gt;li').each(($el, index, $list) =&amp;gt; {
 // $el is a wrapped jQuery element
 if ($el.someMethod() === 'something') {
   //Wrap this element so we can
   // use cypress commands on it
   cy.wrap($el).click()
 } else {
   // do something else
 }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the below test script loads the specified web address and retrieves the DOM element of the input tag on the navbar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Dynamic Dropdown Test', () =&amp;gt; {
    it('should select a specific option from a dynamically loaded dropdown', () =&amp;gt; {
      // Step 1: Visit the page
      cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=common/home');  // Replace with your actual page URL

      // Step 2: Click on the dropdown to trigger the loading of dynamic options and type the text "iPod"
      cy.get('#entry_217822 &amp;gt; div input[placeholder="Search For Products"]').click().clear().type('iPod');  

      // Step 4: iterate over the the returned nodelist and check if "Nano" text exit and click it if Yes
      cy.get('#search &amp;gt; div.search-input-group.flex-fill &amp;gt; div.dropdown &amp;gt; ul li').each(($el, index, $list)=&amp;gt;{
        cy.log($el.text())
        if($el.text() === "Nano"){
            cy.wrap($el).click()
        }
      })
    });
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It clicks on the input tag and types the &lt;em&gt;iPod&lt;/em&gt; text. Then it iterates over all the dynamic dropdowns and checks if the element that contains &lt;em&gt;iPod&lt;/em&gt; matches the content &lt;em&gt;Nano&lt;/em&gt;, and if this is true, a click operation is performed.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Advanced Use Cases of Cypress .select() Commands
&lt;/h2&gt;

&lt;p&gt;When handling dropdowns, some WebElements are hidden or disabled by default, making them difficult to retrieve with the &lt;em&gt;.select()&lt;/em&gt; command in Cypress.&lt;/p&gt;

&lt;p&gt;Let’s look at how to handle disabled and hidden dropdowns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disabled Dropdowns
&lt;/h3&gt;

&lt;p&gt;Disabled dropdowns are select controls set to disable using the disabled property in HTML, or :disabled CSS pseudo-class. Disabled elements prevent users from interacting with the specified WebElement.&lt;/p&gt;

&lt;p&gt;When elements are set to disabled, it stops functioning as usual and does not respond to mouse input, keyboard events, or any other user-stimulated interaction. However, when using the Cypress .select() command, disabled elements are, by default, turned off as false. This means it cannot be selected with the Cypress .select() command.&lt;/p&gt;

&lt;p&gt;To bypass this, the Cypress &lt;em&gt;.select()&lt;/em&gt; command provides a second argument called &lt;em&gt;force&lt;/em&gt; object. The force object takes in a boolean value as &lt;em&gt;true&lt;/em&gt; to enable Cypress to select the &lt;em&gt;disabled&lt;/em&gt; element on the DOM.&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;section class="iphones" id="iphones"&amp;gt;
&amp;lt;h1&amp;gt;Types of iPhone&amp;lt;/h1&amp;gt;
&amp;lt;section id="iphone-versions"&amp;gt;
    &amp;lt;label for="select-version"&amp;gt;Choose an iPhone:&amp;lt;/label&amp;gt;
            &amp;lt;select name="iPhones" id="select-version" disabled&amp;gt;
                &amp;lt;option value=""&amp;gt;--Please choose an option--&amp;lt;/option&amp;gt;
                &amp;lt;option value="iPhone-8"&amp;gt;iPhone 8&amp;lt;/option&amp;gt;
                &amp;lt;option value="iPhone-XR"&amp;gt;iPhone XR&amp;lt;/option&amp;gt;
                &amp;lt;option value="iPhone-11" &amp;gt;iPhone 11&amp;lt;/option&amp;gt;
                &amp;lt;option value="iPhone-12"&amp;gt;iPhone 12&amp;lt;/option&amp;gt;
                &amp;lt;option value="iPhone-13"&amp;gt;iPhone 13&amp;lt;/option&amp;gt;
                &amp;lt;option value="iPhone-14"&amp;gt;iPhone 14&amp;lt;/option&amp;gt;
            &amp;lt;/select&amp;gt;
&amp;lt;/section&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we have a select WebElement with a specified disabled element to prevent user interactions.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;&lt;/em&gt; WebElements with a &lt;em&gt;disabled&lt;/em&gt; property specified, can not be accessed by Cypress. This is the default behavior in Cypress to fix this.&lt;/p&gt;

&lt;p&gt;The Cypress &lt;em&gt;.select()&lt;/em&gt; command is set to receive a second argument as &lt;em&gt;{force: true}&lt;/em&gt;. When the &lt;em&gt;{force: true}&lt;/em&gt; property is applied to an element, Cypress interacts with the element directly without enabling it or removing the disabled property in order to perform a test on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Force Select an Element', () =&amp;gt; {
    it('Force select a disabled element', () =&amp;gt; {
      cy.visit('https://cdpn.io/pen/debug/MYgXLQy?authentication_hash=LQkExWmOvBxA')


      cy.get('#iphone-versions #select-version')


      .select('iPhone 11', {force: true})


      .invoke('val').should('eq', 'iPhone-11')
    })
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the code above, the &lt;em&gt;.select()&lt;/em&gt; command received a second argument as &lt;em&gt;force&lt;/em&gt; and set its &lt;em&gt;value&lt;/em&gt; to true. This enables the Cypress &lt;em&gt;.select()&lt;/em&gt; command to interact with the disabled element while it’s still disabled or hidden.&lt;/p&gt;

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

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

&lt;h2&gt;
  
  
  Hidden Dropdowns
&lt;/h2&gt;

&lt;p&gt;Hidden WebElements are HTML elements styled with &lt;em&gt;display: none&lt;/em&gt; in CSS, making them invisible on the web page.&lt;/p&gt;

&lt;p&gt;In Cypress, hidden elements are typically disabled from interaction. However, to interact with a hidden element, you can use the &lt;em&gt;{force: true}&lt;/em&gt; option, allowing Cypress to forcefully interact with the specified element.&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;section class="mac-book" id="mac-book"&amp;gt;
&amp;lt;h1&amp;gt;Mac Book models released&amp;lt;/h1&amp;gt;
&amp;lt;section id="mac-book-models"&amp;gt;
    &amp;lt;label for="select-version"&amp;gt;Choose a Mac Book:&amp;lt;/label&amp;gt;
            &amp;lt;select name="mac-book" id="select-version" style="display: none;"&amp;gt;
                &amp;lt;option value=""&amp;gt;--Please choose an option--&amp;lt;/option&amp;gt;
                &amp;lt;option value="iMac-Pro"&amp;gt;iMac Pro (27-inch)&amp;lt;/option&amp;gt;
                &amp;lt;option value="MacBook-Air"&amp;gt;MacBook Air (Retina, 13-inch)&amp;lt;/option&amp;gt;
                &amp;lt;option value="Mac-Pro" &amp;gt;Mac Pro&amp;lt;/option&amp;gt;
                &amp;lt;option value="Mac-mini"&amp;gt;MacBook Pro&amp;lt;/option&amp;gt;
                &amp;lt;option value="Mac-Studio"&amp;gt;Mac Studio&amp;lt;/option&amp;gt;
                &amp;lt;option value="MacBook-Air"&amp;gt;MacBook Air&amp;lt;/option&amp;gt;
            &amp;lt;/select&amp;gt;
&amp;lt;/section&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above demonstrates a &lt;em&gt;&lt;/em&gt; element with its display property set to &lt;em&gt;none&lt;/em&gt;, which hides both the &lt;em&gt;&lt;/em&gt; element and its child &lt;em&gt;&lt;/em&gt; tags, preventing them from appearing on the web page.&lt;/p&gt;

&lt;p&gt;Here, the &lt;em&gt;&lt;/em&gt; element is set to &lt;em&gt;display: none&lt;/em&gt;, which automatically removes the element from the DOM. In this case, the element becomes hidden from users and, as a result, stops Cypress from interacting with it.&lt;/p&gt;

&lt;p&gt;To stop the behavior, &lt;em&gt;{force: true}&lt;/em&gt; option is set to the &lt;em&gt;.select()&lt;/em&gt; command, allowing Cypress to interact with the hidden element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Force Select an Element', () =&amp;gt; {

    it('Force select a hidden element', () =&amp;gt; {
      cy.visit('https://cdpn.io/pen/debug/dPbjbwK?authentication_hash=nqAwvJdQxbWr')

      cy.get('#mac-book-models #select-version')

      .select('Mac Studio', {force: true})

      .invoke('val').should('eq', 'Mac-Studio')
    })
  })
&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://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funiahxbbwu3yzsmditpn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funiahxbbwu3yzsmditpn.png" alt=" " width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Select Multiple Elements
&lt;/h3&gt;

&lt;p&gt;The Cypress &lt;em&gt;.select()&lt;/em&gt; command can simultaneously select more than one &lt;em&gt;&lt;/em&gt;. This is very useful as it lets you perform multiple test cases on numerous &lt;em&gt;&lt;/em&gt; WebElements.&lt;/p&gt;

&lt;p&gt;To interact with multiple elements at once, the Cypress &lt;em&gt;.select()&lt;/em&gt; command accepts additional arguments in the form of multiple values. These values correspond to the text content of the &lt;em&gt;&lt;/em&gt; tags that Cypress needs to select.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Select multiple element', () =&amp;gt; {
    it('Select more than one option web element', () =&amp;gt; {
      cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=product/manufacturer/info&amp;amp;manufacturer_id=9')
      cy.get('#entry_212434 #input-sort-212434')


      .select(['Default'], ['Best sellers'], ['Popular'])

    })
  })
&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://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbuwxzcfwno6qodoq4pyd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbuwxzcfwno6qodoq4pyd.png" alt=" " width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Cypress &lt;em&gt;.select()&lt;/em&gt; command selects the options passed as an argument starting from the Default option.&lt;/p&gt;

&lt;p&gt;The above Cypress tests for handling dropdowns are run on the local grid. However, for better scalability and reliability, you can harness the capabilities offered by cloud grids such as LambdaTest.&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-native test execution platform that lets you run tests on the Cypress cloud grid. It offers scalability, intelligent debugging, and AI-driven optimizations to streamline test automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The Cypress &lt;em&gt;.select()&lt;/em&gt; command is a built-in function that interacts and runs tests on the &lt;em&gt;&lt;/em&gt; WebElement and dynamic dropdown in the web application. The &lt;em&gt;&lt;/em&gt; WebElement or dynamic dropdown are web controls that provide a menu or list of options for users on the web.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;.select()&lt;/em&gt; command can interact with dropdowns by their indexes, values, or text content. It can also run tests on multiple WebElements. However, to perform dynamic selection, more advanced techniques are required, such as &lt;em&gt;.contains()&lt;/em&gt; and &lt;em&gt;.each()&lt;/em&gt; Cypress commands.&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>cypressselectcommand</category>
      <category>dynamicdropdown</category>
      <category>staticdropdown</category>
    </item>
    <item>
      <title>35 Best Bootstrap Carousel Examples for 2024</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Fri, 15 Mar 2024 14:40:57 +0000</pubDate>
      <link>https://forem.com/testmuai/35-best-bootstrap-carousel-examples-for-2024-48j7</link>
      <guid>https://forem.com/testmuai/35-best-bootstrap-carousel-examples-for-2024-48j7</guid>
      <description>&lt;p&gt;Liquid syntax error: Tag '{% &lt;a href="https://codepen.io/ocxigin/pen/NWoBeGN" rel="noopener noreferrer"&gt;https://codepen.io/ocxigin/pen/NWoBeGN&lt;/a&gt; %}' was not properly terminated with regexp: /\%\}/&lt;/p&gt;
</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Centering an Image in CSS: A Detailed Guide</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Wed, 13 Mar 2024 18:58:07 +0000</pubDate>
      <link>https://forem.com/testmuai/centering-an-image-in-css-a-detailed-guide-114b</link>
      <guid>https://forem.com/testmuai/centering-an-image-in-css-a-detailed-guide-114b</guid>
      <description>&lt;p&gt;Images are widely used on websites and play an important role in helping users understand and find different types of information on the web. Therefore, proper alignment of images on the websites is crucial to avoid issues like overflow or unnecessary scrolling caused by large images.&lt;/p&gt;

&lt;p&gt;When it comes to working with images, primarily centering an image in CSS can be a challenging task, especially for beginners. This is due to the fact that the &lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; tag works as an internal element; it behaves differently compared to block elements, which complicates the process of centering an image in CSS.&lt;/p&gt;

&lt;p&gt;In this guide, we will explore different methods of centering an image in CSS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This guide will walk you through everything you need to know about &lt;a href="https://www.lambdatest.com/learning-hub/visual-regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated visual regression testing&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why Centering an Image in CSS?
&lt;/h2&gt;

&lt;p&gt;Centering an image in &lt;a href="https://www.lambdatest.com/blog/css3-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;CSS&lt;/a&gt; is very crucial to the overall layout of the webpage. Depending on the approach used, images can be embedded on the web using an HTML &lt;em&gt;&amp;lt; img &amp;gt; *tag or CSS *background-image&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;When an image is embedded on the web due to its large size or repeats within the parent element. To enable the image to fit well on its defined element, it has to be resized to prevent it from overflowing and to take the size of its parent element.&lt;/p&gt;

&lt;p&gt;With this, images can be properly centered and positioned. For example, the illustration below shows how this can be done using three card elements on the web page with the image as a header attached to each element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3044%2F0%2AZ2xrJLFyNQ6Fl2lw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3044%2F0%2AZ2xrJLFyNQ6Fl2lw.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another example can be seen from Etsy, where images are categorized into different sections, each with a fixed width and height of its parent element. This makes it easy to center and position the images across the web page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A0lR1iVjzi0z_0Ott.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A0lR1iVjzi0z_0Ott.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above Etsy website shows good consistency across all elements, contributing to more responsive content, cohesive layout, readability of text, and no overflow of text and images.&lt;/p&gt;

&lt;p&gt;From the Amazon website below, you can see good use of CSS grid in centering images around the webpage. This is very useful as it improves the website layout system and aligns the image element in a cohesive and responsive manner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2708%2F0%2AYrCaRqo4SZb4e39D.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2708%2F0%2AYrCaRqo4SZb4e39D.png" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When images are well-centered, it leads to a structured layout of responsive elements across different viewport sizes. This improves UI aesthetics, cohesive layout, and seamless user experience.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;New to visual testing? Discover the essentials in our comprehensive guide. Learn &lt;a href="https://www.lambdatest.com/learning-hub/visual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;what is visual testing&lt;/a&gt;, why it matters, and how to begin.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Techniques for Centering Images Within the Page
&lt;/h2&gt;

&lt;p&gt;Centering images on the web varies depending on the block level of the containing element (parent) of the image you are trying to center.&lt;/p&gt;

&lt;p&gt;For example, a website like Walmart uses a CSS flexbox and grid to center multiple images on its platform. This makes it more responsive and allows each image to maintain its aspect ratio within its element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2722%2F0%2AZT0aFquIMpPJ8GM7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2722%2F0%2AZT0aFquIMpPJ8GM7.png" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, other methods such as CSS &lt;em&gt;position, transform,&lt;/em&gt; and &lt;em&gt;margin: auto&lt;/em&gt; can also center images across the web page. Depending on how the image is included on the web, such as the &lt;em&gt;&amp;lt; img / &amp;gt;&lt;/em&gt; tag or the &lt;em&gt;background-image&lt;/em&gt; property, we could use the grid, flexbox, CSS &lt;em&gt;position&lt;/em&gt;, &lt;em&gt;margin: auto&lt;/em&gt;, or the &lt;em&gt;translate&lt;/em&gt; property to center images around the web page.&lt;/p&gt;

&lt;p&gt;In the next section of this blog, we will learn different techniques for centering an image in CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Centering an Image in CSS Flexbox
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/css-flexbox?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS flexbox&lt;/a&gt; is a one-dimensional layout system for positioning elements in rows and columns. With flexbox, elements (flex-items) can be positioned within the flex container. The flex container, in this case, refers to the containing element the flex-items are nested in. To position images to the center, &lt;em&gt;justify-content *and *align-items&lt;/em&gt; are used on the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  justify-content and align-items
&lt;/h3&gt;

&lt;p&gt;It is a common practice that images are set to inherit the size of the parent element. This makes it easy to center it across other elements within the webpage.&lt;/p&gt;

&lt;p&gt;With &lt;em&gt;justify-content&lt;/em&gt;, flex-items can be centered horizontally within the parent element, and with &lt;em&gt;align-items&lt;/em&gt;, flex-items can be centered vertically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AQ8Os3fq5EtGWAcnN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AQ8Os3fq5EtGWAcnN.png" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we combined*justify-content* and &lt;em&gt;align-items&lt;/em&gt; to center the flex-items on the horizontal and vertical axis.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Flexbox -- flex-item&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" /&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main class="container"&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;div class="img-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794539-fc01d463-7bad-4887-a02a-2b9c3eed891f.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="btn"&amp;gt;
                &amp;lt;aside&amp;gt;
                    &amp;lt;button&amp;gt;
                        &amp;lt;span"&amp;gt;Book a Call&amp;lt;/span&amp;gt;
                        &amp;lt;i class="fa-solid fa-envelope"&amp;gt;&amp;lt;/i&amp;gt;
                    &amp;lt;/button&amp;gt;

                    &amp;lt;button&amp;gt;
                        &amp;lt;span&amp;gt;Download Porfolio&amp;lt;/span&amp;gt;
                        &amp;lt;i class="fa-solid fa-arrow-down"&amp;gt;&amp;lt;/i&amp;gt;
                    &amp;lt;/button&amp;gt;
                &amp;lt;/aside&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
               &amp;lt;p&amp;gt; 
                &amp;lt;strong&amp;gt;Aarav Sharma&amp;lt;/strong&amp;gt; is a highly innovative UX designer known for his ability to seamlessly blend user-centered design principles with cutting-edge technology. With a keen eye for detail and a passion for creating intuitive digital experiences, Sharma has played a pivotal role in revolutionizing user interfaces across various platforms.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, within the HTML tag, the following tags performed the functions below&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt; main &amp;gt;&lt;/em&gt;:&lt;/strong&gt; With a class of container, this tag serves as the parent tag of the card element on the webpage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt; section &amp;gt;&lt;/em&gt;:&lt;/strong&gt; A nested tag of the &amp;lt; main &amp;gt; tag that serves as a wrapper for both the image, buttons, and content of the card element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt;:&lt;/strong&gt; Here, we parse in a user profile as the hero image of the card element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt; button &amp;gt;&lt;/em&gt;:&lt;/strong&gt; We implement two buttons to serve as a call to action on the card element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt; p &amp;gt;&lt;/em&gt;:&lt;/strong&gt; The paragraph tag contains the content on the page.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These HTML tags are used to structure the page content, while the CSS below is used to style it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore the best 25 &lt;a href="https://www.lambdatest.com/blog/visual-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated visual testing&lt;/a&gt; tools for a seamless user experience in 2024. Find your perfect tool today with our comprehensive list.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; body {
        width: 100vw;
        height: 100vh;
        background-color: var(--gray-1);
    }

    :root {
        --transparent: rgba(1, 1, 1, 0);

        --black-0: #010101;
        --black-1: #111317;
        --black-2: #22262e;
        --black-3: #2b2f39;

        --gray-0: #6e7a92;
        --gray-1: #f4f5f8;
        --gray-2: #d3d7de;
        --gray-3: #a6aebc;

        --gradient-1: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 50%, rgba(0,212,255,1) 100%);
    }

    .container {
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;

    }

    .container section {
        position: relative;
        width: 22em;
    }

    .container img {

        border-radius: 10px;
        width: 100%;
        height: auto;
    }

    .container .btn {
        width: 100%;
        position: absolute;
        bottom: 30%;

        left: 0px;
    }

    button {
        display: flex;
        justify-content: space-between;
        padding:3px;
        line-height: 3em;
        background-color: var(--gray-1);
        border: none;
        border-radius: 100px;
        cursor: pointer;
        color: var(--black-1);
        transition: 0.5s all;
    }

    button:last-child {
        background-color: var(--transparent);
        border: 2px solid var(--gray-1);
        color: var(--gray-1)
    }

    button:hover {
        background: var(--black-2);
        color: var(--gray-1);
    }

    i {
        display: inline-block;
        padding: 1em;
        border-radius: 100px;
        line-height: 100%;
        background-color: var(--black-0);
        color: var(--gray-1);
    }

    span {
        display: inline-block;
        padding: 0 10px;
    }

    aside {
        display: flex;
        justify-content: space-around;
    }

    .content p {
        font-family: calibri;
        color: var(--black-3);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To center the card element from the horizontal and vertical axes, we do the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The body element is set at a &lt;em&gt;width&lt;/em&gt; and &lt;em&gt;height&lt;/em&gt; of &lt;em&gt;100vw&lt;/em&gt; and &lt;em&gt;100vh&lt;/em&gt;, respectively, providing enough space for the element to be positioned around the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &amp;lt; main &amp;gt; element with the class &lt;em&gt;container&lt;/em&gt; is set to &lt;em&gt;display flex&lt;/em&gt; to help center the entire content to the center of the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &amp;lt; section &amp;gt; tag is set to &lt;em&gt;relative&lt;/em&gt; and a &lt;em&gt;width&lt;/em&gt; of &lt;em&gt;22em&lt;/em&gt; to serve as the &lt;em&gt;width&lt;/em&gt; of the children element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; tag takes a &lt;em&gt;width&lt;/em&gt; of &lt;em&gt;100%&lt;/em&gt;&amp;gt; to inherit the parent default &lt;em&gt;width&lt;/em&gt; size and &lt;em&gt;height&lt;/em&gt; of auto.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;&amp;lt; button &amp;gt;&lt;/em&gt; tags are styled as CTA buttons with a transparent background and a background of gray on hover.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each element within the parent card element is styled to fit into the parent container for easy alignment around the webpage.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/RwdRYKb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  flex-self
&lt;/h3&gt;

&lt;p&gt;From the previous example, we learned how &lt;em&gt;justify-content&lt;/em&gt; and &lt;em&gt;align-items&lt;/em&gt; are used to center flex-items within their container. When in use, &lt;em&gt;justify-content&lt;/em&gt; and &lt;em&gt;align-items&lt;/em&gt; affect all flex-items within the container.&lt;/p&gt;

&lt;p&gt;However, where a particular flex item is required to be repositioned aside from other flex items within the same container, &lt;em&gt;flex-self&lt;/em&gt; is used. The &lt;em&gt;flex-self&lt;/em&gt; helps reposition each flex item within its flex container.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Boost your testing efficiency with LambdaTest’s &lt;a href="https://www.lambdatest.com/test-intelligence/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Test Intelligence&lt;/a&gt;. Gain valuable insights, flaky test trends, and accelerate your release cycles. Try LambdaTest today!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here each flex item is repositioned using the &lt;em&gt;flex-self&lt;/em&gt; property.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Flexbox -- flex-self&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;aside&amp;gt;
            &amp;lt;!-- Header --&amp;gt;
            &amp;lt;section&amp;gt;                
                &amp;lt;p&amp;gt; Centering Image in CSS: Flexbox -- flex-self&amp;lt;/p&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Body --&amp;gt;
            &amp;lt;section&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794566-f2111e6a-b8be-47c0-a12f-d4db30793ebf.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;

                &amp;lt;div&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794566-f2111e6a-b8be-47c0-a12f-d4db30793ebf.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;

                &amp;lt;div&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794566-f2111e6a-b8be-47c0-a12f-d4db30793ebf.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

        &amp;lt;/aside&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; :root {
        --transparent: rgba(1, 1, 1, 0);

        --black-0: #010101;
        --black-1: #111317;
        --black-2: #22262e;
        --black-3: #2b2f39;

        --gray-0: #6e7a92;
        --gray-1: #f4f5f8;
        --gray-2: #d3d7de;
        --gray-3: #a6aebc;

        --gradient-1: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 50%, rgba(0,212,255,1) 100%);
    }
        body {
            width: 100vw;
            height: 100vh;
            background-color: var(--gray-2);
        }
        aside {
            background-color: var(--gray-1);
            width: 80%;
            margin: 1em auto;
            border-radius: 1em;
            padding-bottom: 2em;
        }

        section:first-child {
            width: 80%;
            border-radius: 1em;
            margin: 3em auto 0;
            line-height: 4em;
            background: var(--gradient-1);
        }

        p {
            color: var(--gray-1);
            text-align: center;
            font-family: calibri;
            font-size: 2em;
        } 

        section:last-child {
            display: flex;
            justify-content: center;
            gap: 3em;
            width: 80%;
            height: 20em;
            margin: 2em auto;
            border-radius: 1em;
            border: 1px solid var(--gray-0);
        }

        div {
            width: 120px;
        }

        img {
            width: 100%;
            border-radius: 10px;
        }

        div:nth-child(1) {
            align-self: start;
        }

        div:nth-child(2) {
            align-self: center;
        }

        div:nth-child(3) {
            align-self: end;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code example above, we have a parent container (&lt;em&gt;&amp;lt; section &amp;gt;&lt;/em&gt; tag) with three child elements (&lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; tags). The parent element is set to a &lt;em&gt;display&lt;/em&gt; of &lt;em&gt;flex&lt;/em&gt;, and each child element is set to &lt;em&gt;start, center,&lt;/em&gt; and &lt;em&gt;end,&lt;/em&gt; respectively, within the flex-container.&lt;/p&gt;

&lt;p&gt;The black solid border around the parent element (&lt;em&gt;&amp;lt; section &amp;gt;&lt;/em&gt; tag) serves as a visual reference to the amount of space within the parent element and how each flex item (images) is positioned with the flex container.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/jOJrowv?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Read through the blog to understand what is &lt;a href="https://www.lambdatest.com/blog/test-observability/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test observability&lt;/a&gt; and how it can improve your testing process.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Centering an Image in CSS Grid
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/blog/css-grid/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS grid&lt;/a&gt; system is a two-dimensional layout method for positioning elements around the web page. The CSS grid is the most powerful CSS layout system that enables web elements to be positioned between rows and columns at the same instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  place-content
&lt;/h3&gt;

&lt;p&gt;The CSS grid system comes with lots of properties, such as ways for positioning grid items within the grid container. One of which is the &lt;em&gt;place-content&lt;/em&gt; property. The CSS grid &lt;em&gt;place-content&lt;/em&gt; property is a short-hand property for &lt;em&gt;align-content&lt;/em&gt; and &lt;em&gt;justify-content&lt;/em&gt; properties.&lt;/p&gt;

&lt;p&gt;This is very useful when you need to set grid items within the grid container. The &lt;em&gt;place-content&lt;/em&gt; property aligns the &lt;em&gt;grid items&lt;/em&gt; with the &lt;em&gt;grid cells&lt;/em&gt; in a horizontal and vertical direction within the grid container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2722%2F0%2AjIrJ1QYZqUfTfKzB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2722%2F0%2AjIrJ1QYZqUfTfKzB.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the grid &lt;em&gt;place-content&lt;/em&gt; property is used to position the grid items along the horizontal and vertical axes.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Gird - place-items&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794558-047ca72b-9fe0-42f7-8d8e-09c77d48d3c0.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794595-9f1358ea-5af5-4b69-8295-bde8961fed84.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794606-8b10b1c2-16e0-431d-88ca-3d6c9fca4839.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794613-9a465af6-5635-4a85-badd-42c94a2c4bda.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; :root {
            --neutral-200: rgb(229 229 229);
            --amber-200: rgb(254 243 199);
            --amber-600: rgb(217 119 6);
            --amber-800: rgb(146 64 14);
        }
        body {
            width: 100vw;
        }
        section {
            display: grid;
            grid-template-columns: repeat(4, 200px);
            gap: 5px;
            place-content: center;
            height: 100vh;
        }

        div {
            width: 20em;
            height: 20em;
            position: relative;
            border: 2px dashed var(--amber-800);
            padding: 2px;
            border-radius: 100px;
        }


        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 100px;
        }

        @media screen and (max-width:1160px) {
            div {
            width: 10em;
            height: 10em;
            gap: 20px;

        }
        }

        @media screen and (max-width:800px) {
            section {
            grid-template-columns: repeat(2, 200px);
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The code above can be broken into sections as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;section&lt;/em&gt; tag is the parent tag, nested inside this tag are four &lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; tags. The &lt;em&gt;section&lt;/em&gt; tag is set to &lt;em&gt;display&lt;/em&gt; a grid and a &lt;em&gt;place-content&lt;/em&gt; property to center the content around the webpage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The image tags are set to a &lt;em&gt;width&lt;/em&gt; and &lt;em&gt;height&lt;/em&gt; of &lt;em&gt;20em&lt;/em&gt; and position &lt;em&gt;relative&lt;/em&gt; to the &lt;em&gt;section&lt;/em&gt; tag.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;section&lt;/em&gt; tags contain four direct children elements; using the &lt;em&gt;place-content&lt;/em&gt; helps align all items around the container.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/qBvNGXO?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Discover 58 top &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;QA automation tools&lt;/a&gt; in 2024 for powerful and efficient testing solutions.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  place-items
&lt;/h3&gt;

&lt;p&gt;The CSS grid &lt;em&gt;place-items&lt;/em&gt; property is used to align the grid items in a horizontal and vertical direction within the individual grid cells in a grid container. The &lt;em&gt;place-items&lt;/em&gt; property is a shorthand property for &lt;em&gt;justify-items&lt;/em&gt; (horizontal alignment) and &lt;em&gt;align-items&lt;/em&gt; (vertical alignment) used to control the alignment of grid items within their grid cells.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2728%2F0%2A-DKkEXqiVx8f7iU4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2728%2F0%2A-DKkEXqiVx8f7iU4.png" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;em&gt;place-item&lt;/em&gt; property, each grid item is aligned within its grid cells. The grid cells are single-units of boxes arranged in a row and column layout within the grid container. When a grid is defined as a container, each grid item is assigned a cell. However, the &lt;em&gt;place-items&lt;/em&gt; property lets us align the grid items within their cells.&lt;/p&gt;

&lt;p&gt;To see a visual reference on &lt;em&gt;place-items&lt;/em&gt; alignment on the cell, We can turn on the Chrome DevTools and click on the small grid icon on the element tab as indicated below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2730%2F0%2A7aUMZ_ivGbUkBq5T.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2730%2F0%2A7aUMZ_ivGbUkBq5T.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The grid cells are the square boxes around the card elements; from the image above, you can see how each card element is aligned to the center of their grid cells.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; :root {
            --neutral-200: rgb(229 229 229);
            --amber-200: rgb(254 243 199);
            --amber-600: rgb(217 119 6);
            --amber-800: rgb(146 64 14);
        }
        body {
            width: 100vw;
        }
        section {
            display: grid;
            grid-template-columns: repeat(4, 200px);
            gap: 5px;
            place-content: center;
            height: 100vh;
        }

        div {
            width: 20em;
            height: 20em;
            position: relative;
            border: 2px dashed var(--amber-800);
            padding: 2px;
            border-radius: 100px;
        }


        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 100px;
        }

        @media screen and (max-width:1160px) {
            div {
            width: 10em;
            height: 10em;
            gap: 20px;

        }
        }

        @media screen and (max-width:800px) {
            section {
            grid-template-columns: repeat(2, 200px);
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; *,*::after, *::before {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --lt-lightColor: #0ebac5;
            --lt-darkColor: #09777e;
            --gray-03: rgb(229 231 235); 
            --gray-05: rgb(107 114 128);
            --gray-08: rgb(31 41 55);
        }

        body {
            background-color: var(--gray-03);
            display: flex;
            justify-content: center;
        }

       .parent {
            display: grid;
            grid-template-columns: repeat(2, 400px);
            grid-template-rows: 400px;
            gap: 10px;
            place-items: center;

            padding: 10px;

            box-shadow: inset 2px 2px 15px rgba(0, 0, 0, .4);
        }

        .children {
            background-color: white;
            width: 200px;
            height:-moz-fit-content;
            height: -webkit-fit-content;
            height: fit-content;
            padding:10px;
            border-radius: 10px;
        }

        .children h1 {
            font-size: 22px;
            font-family: calibri;
            text-transform: uppercase;
            font-weight: lighter;
            color: var(--lt-lightColor);
        }

        .children .price {
            font-family: calibri;
            font-weight: bold;
            color: var(--lt-darkColor);
            margin: 5px 0;
        }

        .children .description {
            font-family: calibri;
            color: var(--gray-05);
            font-size: 14px;
        }

        .children img {
            aspect-ratio: 1/1;
            width: 100%;
            border-radius: inherit;
        }

        @media screen and (max-width: 800px){
            .parent {
                grid-template-columns: repeat(1, 400px);
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code sample above, we have four &lt;em&gt;&amp;lt; aside &amp;gt;&lt;/em&gt; elements with classes of &lt;em&gt;child1&lt;/em&gt; to &lt;em&gt;child4&lt;/em&gt; and &lt;em&gt;children&lt;/em&gt; and an &amp;lt; section &amp;gt; element with a class of &lt;em&gt;parent&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;parent:&lt;/strong&gt; The &lt;em&gt;parent&lt;/em&gt; class is set to &lt;em&gt;display&lt;/em&gt; a &lt;em&gt;grid&lt;/em&gt; to make the element a grid container, then a &lt;em&gt;grid-template-columns&lt;/em&gt; is set to &lt;em&gt;repeat(2, 400px)&lt;/em&gt; and a &lt;em&gt;grid-template-rows: 400px;&lt;/em&gt; this will provide more space for cells within the grid container and split them into a two-column grid. The gap of &lt;em&gt;10px&lt;/em&gt; creates a space between the cells, and the &lt;em&gt;place-items&lt;/em&gt; property sets the grid-items to center horizontally and vertically within the grid cell.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;children:&lt;/strong&gt; The &lt;em&gt;children&lt;/em&gt; class is the &lt;em&gt;grid-items&lt;/em&gt;. It takes a width of &lt;em&gt;200px&lt;/em&gt; each within the grid container.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When centering an image, the &lt;em&gt;place-items&lt;/em&gt; align the image within the cells of the grid container, which is very useful for websites with multiple images.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/XWGBqEJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Our &lt;a href="https://www.lambdatest.com/free-online-tools/js-obfuscator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JS Obfuscator&lt;/a&gt; encrypts your code, making it unreadable to anyone who doesn’t have the key. Protect your code from theft and hacking with just a few clicks.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  justify-self
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;justify-self&lt;/em&gt; property functions the same way as the &lt;em&gt;flex-self&lt;/em&gt; property but for the grid system.&lt;/p&gt;

&lt;p&gt;With the &lt;em&gt;justify-self&lt;/em&gt; property, individual grid items can be re-aligned within the grid container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2728%2F0%2Ao_hHiufBv3x9XPzl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2728%2F0%2Ao_hHiufBv3x9XPzl.png" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the example above, the first grid item is set to align to the &lt;em&gt;end&lt;/em&gt; of its appropriate axis, while the third grid item is set to &lt;em&gt;start&lt;/em&gt; from the appropriate axis.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Gird - justify-self&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/284007720-d35c5f72-8d64-4ed8-8afc-f539a2a53d7e.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/284007721-72475fa5-bf2c-4689-85fb-42afc1ac05ae.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/284007729-f1549eaf-fb3b-4bbb-99c2-a9d51f7e25d0.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/284007728-51f5c876-537d-4fd7-aaca-cac078ff718b.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/284007726-7bfc1eaa-4536-480c-a017-4977b5f43fca.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/284007732-459ad872-1f92-45d9-aa6a-7b9010f7645b.jpg" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    :root {
        --teal-400: rgb(45 212 191);
        --teal-500: rgb(20 184 166);
        --teal-600: rgb(13 148 136);
        --teal-700: rgb(15 118 110);
        --teal-800: rgb(17 94 89);
        --teal-900: rgb(19 78 74);
    }
    body {
        width: 100vw;
        height: 100vh;
    }

    section {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 300px;
        justify-content: center;
        align-content: center;
        gap: 10px;
    }

    div {
        border: 2px solid var(--teal-900);
        background-color: var(--teal-400);
        transition: all 1s ease-out;
    }

    div:nth-child(1){
        justify-self: end;
    }

    div:nth-child(3){
        justify-self: start;
    }

    div:nth-child(5){
        animation-name: roll;
        animation-duration: 1s;
        animation-delay: 0s;
        animation-timing-function: linear;
        animation-iteration-count: infinite;
        animation-fill-mode: forwards;
        animation-direction: alternate;
    }

    img {
        width: 200px;
    }

    @keyframes roll {
        0% {
            justify-self: start;
        }

        50%{
            justify-self: center;
        }

        100% {
            justify-self: end;
        }
    }

@media screen and (max-width: 600px){
    section {
        grid-template-columns: repeat(2, 1fr);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, &lt;em&gt;&amp;lt; section &amp;gt; *tag serves as the parent tag with six direct *&amp;lt; img &amp;gt; *elements. The *&amp;lt; section &amp;gt; *element is set to a *display&lt;/em&gt; of &lt;em&gt;grid&lt;/em&gt; and &lt;em&gt;grid-template-column&lt;/em&gt; of &lt;em&gt;3&lt;/em&gt;. With these, each &lt;em&gt;grid&lt;/em&gt; item is split into 3 columns around the grid-container. With &lt;em&gt;justify-self&lt;/em&gt;, individual items are re-aligned within the grid-container.&lt;/p&gt;

&lt;p&gt;For example, the &lt;em&gt;div:nth-child(1)&lt;/em&gt; is set to &lt;em&gt;justify-self: end&lt;/em&gt; to reposition the image to the &lt;em&gt;end&lt;/em&gt; position with the grid container.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/bGZeyrv?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Streamline your SQL code by removing unnecessary spaces and comments with our &lt;a href="https://www.lambdatest.com/free-online-tools/sql-minify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;SQL minify&lt;/a&gt; tool that enhances your code’s readability and reduces size. Try it today!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  margin: auto
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;margin&lt;/em&gt; property can be set to &lt;em&gt;auto&lt;/em&gt; to automatically align an image in a block container to the center, based on the size of the parent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ANxeHyLgoEMRhRlc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ANxeHyLgoEMRhRlc4.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Specified element will occupy the space set by the &lt;em&gt;width&lt;/em&gt; property and minus its width from the parent width.&lt;/p&gt;

&lt;p&gt;The element will then be positioned in the middle of the page or containing the element, leaving the same proposition of space left and right of the element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2726%2F0%2A0MxQDKoIIhemHO88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2726%2F0%2A0MxQDKoIIhemHO88.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main&amp;gt;
    &amp;lt;section&amp;gt;
       &amp;lt;img src="https://user-images.githubusercontent.com/78242022/285645398-c1c1eec5-4e16-4a68-9216-b555264e7c10.jpg" alt=""&amp;gt;
     &amp;lt;/section&amp;gt;
 &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main {
            width: 100vw;
            height: 100vh;
        }

        section {
            width: 50%;
            margin: 0 auto;
        }

        img {
            width: 100%;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;em&gt;margin: auto&lt;/em&gt; is mainly used for block elements. As you can see from the code sample above, the &lt;em&gt;&amp;lt; section &amp;gt; *tag is set to occupy *50%&lt;/em&gt; of the parent container within the webpage. A &lt;em&gt;margin: 0 auto&lt;/em&gt; is set to push the child element to the center of the page.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/yLwgapa?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  position
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;position&lt;/em&gt; property is an effective way to center an image. With the &lt;em&gt;position&lt;/em&gt; property, images or elements can be centered or positioned around the document using the &lt;em&gt;position&lt;/em&gt; properties such as &lt;em&gt;left&lt;/em&gt;, &lt;em&gt;right&lt;/em&gt;, &lt;em&gt;top&lt;/em&gt;, and &lt;em&gt;bottom&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;position: absolute&lt;/em&gt; property changes the stacking context of the document. Adding &lt;em&gt;position: relative&lt;/em&gt; can help images or elements be centered around the parent element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AH5QmQMvy-ocGtNTq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AH5QmQMvy-ocGtNTq.png" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Position&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" /&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;aside class="card"&amp;gt;
                &amp;lt;heading&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/286496886-005700e0-daf3-4029-ad07-8d69f94f143a.jpg" alt=""&amp;gt;
                &amp;lt;/heading&amp;gt;
                &amp;lt;article&amp;gt;
                    &amp;lt;div class="profile"&amp;gt;
                        &amp;lt;figure&amp;gt;
                            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/283794643-4cea087e-3214-4331-84f8-fde21a8f22db.jpg" alt=""&amp;gt;
                        &amp;lt;/figure&amp;gt;
                        &amp;lt;p class="para name"&amp;gt;Natalie Lynn&amp;lt;/p&amp;gt;

                    &amp;lt;/div&amp;gt;

                    &amp;lt;div&amp;gt;
                        &amp;lt;h1 class="heading-post"&amp;gt;5 Best Coffee Shops&amp;lt;/h1&amp;gt;
                        &amp;lt;p class="para-content"&amp;gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat repudiandae modi doloremque harum repellendus ipsam aliquid dolorum architecto dolorem velit!&amp;lt;/p&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;hr /&amp;gt;
                    &amp;lt;div class="reactions"&amp;gt;
                        &amp;lt;p class="para view"&amp;gt;3k views&amp;lt;/p&amp;gt;
                        &amp;lt;p class="para comments"&amp;gt;153 comments&amp;lt;/p&amp;gt;
                        &amp;lt;p class="para likes"&amp;gt;534 &amp;lt;i class="fa-solid fa-heart"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/article&amp;gt;
            &amp;lt;/aside&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; *, 
        *::before, 
        *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        main {
            background-color: rgb(161, 99, 5);
            width: 100vw;
            height: 100svh;
            position: relative;
        }

        .card {
            width: 20em;
            background-color: #fff;
            border-radius: 10px;

            position: absolute;
            top: 50%;
            left: 50%;

            transform: translate(-50%, -50%);

            box-shadow: 0px 3px 2px 15px rgba(0, 0, 0, .4);
        }

        heading img {
            border-top-right-radius: 10px;
            border-top-left-radius: 10px;
        }

        img {
            width: 100%;
        }

        .heading-post {
            font-size: 1.5em;
            font-family: calibri;
            margin: 10px 0;
        }

        .profile {
            display: flex;
            justify-content: start;
            gap: 10px;
        }

        figure {
            display: block;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: red;
        }

        figure img {
            width: 100%;
            height: 100%;
            object-position: left bottom;
            border-radius: 100px;
        }
        .para-content {
            font-size: 18px;
            font-family: calibri;
            padding-bottom: 20px;
        }

        .para {
            font-size: 14px;
            font-family: calibri;
            color: rgb(94, 94, 94);
        }

        .name {
            transform: translateY(20px);

        }

        .reactions {
            justify-content: space-between;
            display: flex;
            gap: 20px;
            margin-top: 10px;
        }

        article {
            padding: 0.5em 1em;
        }

        i {
            color: red;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the above code, the &lt;em&gt;position&lt;/em&gt; property effect can be seen from the &lt;em&gt;position: absolute&lt;/em&gt;, &lt;em&gt;top: 50%&lt;/em&gt;, and &lt;em&gt;left: 50%&lt;/em&gt;. This helps reposition the card element at the center of the page relative to the  &amp;lt; main &amp;gt; element.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/gOEgWvM?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Struggling with messy &lt;a href="https://www.lambdatest.com/free-online-tools/php-beautifier?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;PHP Beautifier&lt;/a&gt; Online scripts? Our PHP Formatter &amp;amp; Beautifier Online tool provides clean and structured formatting. Beautify your code and Improve readability today!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  transform: translate
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;translate&lt;/em&gt; property sets how elements can be repositioned from their initial layout or document flow. For example, we could reposition images or elements around the document. To do this, we use the &lt;em&gt;transform: translate&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;transform: translate&lt;/em&gt; property has both X (horizontal) and Y (vertical) coordinates for horizontal and vertical positioning.&lt;/p&gt;

&lt;p&gt;By default, elements are set to &lt;em&gt;translate: 0px&lt;/em&gt;, meaning no translation is set. Using the length &lt;a href="https://www.lambdatest.com/blog/css-units/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS units&lt;/a&gt; like &lt;em&gt;px&lt;/em&gt;, &lt;em&gt;em&lt;/em&gt;, &lt;em&gt;rem&lt;/em&gt;, and &lt;em&gt;%&lt;/em&gt;, images can be repositioned around the webpage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AT-fCqtQjTjdFF-Cc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AT-fCqtQjTjdFF-Cc.png" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Transform&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" /&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;!-- One --&amp;gt;
            &amp;lt;aside class="card one"&amp;gt;
                &amp;lt;div class="img-wrap"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296800486-ffbf5777-4874-48c1-a162-31ee0f9ed7c8.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content-wrap"&amp;gt;
                    &amp;lt;h1&amp;gt;Fujifilm X-T10 Camera&amp;lt;/h1&amp;gt;
                    &amp;lt;p&amp;gt;$350&amp;lt;/p&amp;gt;
                    &amp;lt;button&amp;gt;Book Now&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;

            &amp;lt;!-- Two --&amp;gt;
            &amp;lt;aside class="card two"&amp;gt;
                &amp;lt;div class="img-wrap"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296800474-7f5d69c1-1829-414c-a8d3-0479b6b8697c.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content-wrap"&amp;gt;
                    &amp;lt;h1&amp;gt;NIKON D7200 Camera&amp;lt;/h1&amp;gt;
                    &amp;lt;p&amp;gt;$500&amp;lt;/p&amp;gt;
                    &amp;lt;button&amp;gt;Book Now&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;

            &amp;lt;!-- Three --&amp;gt;
            &amp;lt;aside class="card three"&amp;gt;
                &amp;lt;div class="img-wrap"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296800461-933e65ef-705c-42c2-adf5-0e04053bcfec.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content-wrap"&amp;gt;
                    &amp;lt;h1&amp;gt;NIKON D810 Camera&amp;lt;/h1&amp;gt;
                    &amp;lt;p&amp;gt;$230&amp;lt;/p&amp;gt;
                    &amp;lt;button&amp;gt;Book Now&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Centering Image in CSS: Transform&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" /&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;!-- One --&amp;gt;
            &amp;lt;aside class="card one"&amp;gt;
                &amp;lt;div class="img-wrap"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296800486-ffbf5777-4874-48c1-a162-31ee0f9ed7c8.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content-wrap"&amp;gt;
                    &amp;lt;h1&amp;gt;Fujifilm X-T10 Camera&amp;lt;/h1&amp;gt;
                    &amp;lt;p&amp;gt;$350&amp;lt;/p&amp;gt;
                    &amp;lt;button&amp;gt;Book Now&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;

            &amp;lt;!-- Two --&amp;gt;
            &amp;lt;aside class="card two"&amp;gt;
                &amp;lt;div class="img-wrap"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296800474-7f5d69c1-1829-414c-a8d3-0479b6b8697c.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content-wrap"&amp;gt;
                    &amp;lt;h1&amp;gt;NIKON D7200 Camera&amp;lt;/h1&amp;gt;
                    &amp;lt;p&amp;gt;$500&amp;lt;/p&amp;gt;
                    &amp;lt;button&amp;gt;Book Now&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;

            &amp;lt;!-- Three --&amp;gt;
            &amp;lt;aside class="card three"&amp;gt;
                &amp;lt;div class="img-wrap"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296800461-933e65ef-705c-42c2-adf5-0e04053bcfec.jpg" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content-wrap"&amp;gt;
                    &amp;lt;h1&amp;gt;NIKON D810 Camera&amp;lt;/h1&amp;gt;
                    &amp;lt;p&amp;gt;$230&amp;lt;/p&amp;gt;
                    &amp;lt;button&amp;gt;Book Now&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code sample above, the section element contains three card elements, and each element is set to a &lt;em&gt;transform: translate&lt;/em&gt; of &lt;em&gt;150%&lt;/em&gt; on the horizontal axis and &lt;em&gt;100%&lt;/em&gt; on the vertical axis to realign the element around the webpage.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/dyrNJyZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Convert your XML files to JSON format without any hassle using our reliable and efficient &lt;a href="https://www.lambdatest.com/free-online-tools/xml-to-json-converter?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;XML to JSON converter&lt;/a&gt; tool. No installation or download required.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Techniques for Centering an Image in CSS Within Container
&lt;/h2&gt;

&lt;p&gt;Depending on how the image is included on the web, such as the &lt;em&gt;&amp;lt; img /&amp;gt; *tag or the *background-image&lt;/em&gt; property we could use &lt;em&gt;object-position&lt;/em&gt; or &lt;em&gt;background-position&lt;/em&gt; CSS property to center images within its container. The image container refers to the element in which the image is embedded.&lt;/p&gt;

&lt;p&gt;In this blog section on centering an image in CSS, we will learn different techniques that can be implemented to center an image within the container of the image using CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  background-position
&lt;/h2&gt;

&lt;p&gt;The CSS &lt;em&gt;background-position&lt;/em&gt; property is used to position images set by the &lt;em&gt;background-image&lt;/em&gt; property within the element container. With the &lt;em&gt;background-position&lt;/em&gt; property, we can specify the image’s position within the element container based on the value provided.&lt;/p&gt;

&lt;p&gt;These values, however, consist of keywords &lt;em&gt;top&lt;/em&gt;, &lt;em&gt;button&lt;/em&gt;, &lt;em&gt;left&lt;/em&gt;, &lt;em&gt;right&lt;/em&gt;, and &lt;em&gt;center&lt;/em&gt; — length units like &lt;em&gt;px&lt;/em&gt;, &lt;em&gt;em&lt;/em&gt;, &lt;em&gt;rem&lt;/em&gt;,and &lt;em&gt;%&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ASYB_s7mzXSpa3maq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ASYB_s7mzXSpa3maq.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, the &lt;em&gt;background-position&lt;/em&gt; property exists on X (horizontal) and Y (vertical) coordinates. With this, images can be positioned on a single coordinate or both (axis).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2722%2F0%2AT8kkM0ZakWzjtHqm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2722%2F0%2AT8kkM0ZakWzjtHqm.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;CSS Background position property&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;p&amp;gt;Click the button to re-position the image within it container&amp;lt;/p&amp;gt;
        &amp;lt;/section&amp;gt;
        &amp;lt;section class="container"&amp;gt;
            &amp;lt;aside class="btn"&amp;gt;
                &amp;lt;button&amp;gt;Top&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;Left&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;Bottom&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;25% 75%&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;Right&amp;lt;/button&amp;gt;
            &amp;lt;/aside&amp;gt;
            &amp;lt;aside class="bg-img"&amp;gt;

            &amp;lt;/aside&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main {
            width: 100vw;
            height: 100svh;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .container {
            width: 400px;
            height: 250px;
            border: 4px solid rgb(252, 60, 92);
            display: flex;
        }

        .btn {
            width: 30%;
            height: 100%;
            background: rgb(255, 225, 230);
        }

        button {
            width: 100%;
            line-height: 40px;
            background-color: antiquewhite;
            border: 4px solid rgb(252, 60, 92);
            transition: background 0.5s linear;
        }
        button:hover {
            background-color: rgb(252, 60, 92);
        }
        button:active {
            box-shadow: inset 2px 2px 2px 2px rgba(0, 0, 0, 0.5);
        }

        .bg-img {
            width: 70%;
            height: 100%;
            background: rgb(255, 169, 183);
            background-image: url("https://user-images.githubusercontent.com/78242022/296800461-933e65ef-705c-42c2-adf5-0e04053bcfec.jpg");
             transition: all 0.5s linear;
            background-repeat: no-repeat;
            background-size: 150px 100px;

            background-position: center;
        }

        p {
            font-family: calibri;
            font-size: 18px;
            color: #8d8989;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const bgImage = document.querySelector('.bg-img');

        const allButtons = document.querySelectorAll('button');

        allButtons.forEach((button, idx)=&amp;gt; {
            if(idx === 0) {
                button.addEventListener('click', (e)=&amp;gt;{
                    bgImage.style.backgroundPosition = 'top';
                })
            }

            if(idx === 1) {
                button.addEventListener('click', (e)=&amp;gt;{
                    bgImage.style.backgroundPosition = 'left';
                })
            }

            if(idx === 2) {
                button.addEventListener('click', (e)=&amp;gt;{
                    bgImage.style.backgroundPosition = 'bottom';
                })
            }

            if(idx === 3) {
                button.addEventListener('click', (e)=&amp;gt;{
                    bgImage.style.backgroundPosition = '25% 75%';
                })
            }

            if(idx === 4) {
                button.addEventListener('click', (e)=&amp;gt;{
                    bgImage.style.backgroundPosition = 'right';
                })
            }
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, from the code above, we have the following functions&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;bgImage&lt;/em&gt; variable is used to store the background element. With this, an element can manipulate the background position of the image parsed to the element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;allButtons&lt;/em&gt; variable is used to store all the button elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the &lt;em&gt;allButtons&lt;/em&gt; variable, we added a &lt;em&gt;forEach&lt;/em&gt; function to loop through each returned element (node list) and add an &lt;em&gt;eventListener&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Using the if statement to check and change the background position of the element, if the index of the element clicked on is equal to the value parsed in.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.lambdatest.com/free-online-tools/json-to-xml-converter?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;**JSON to XML Converter&lt;/a&gt; is a simple and fast tool that converts JSON to XML data. Use this tool to convert your JSON documents into valid XML for easy data exchange.**&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  object-position
&lt;/h2&gt;

&lt;p&gt;When images are included using the &lt;em&gt;&amp;lt; img /&amp;gt; *tag, using the *object-position&lt;/em&gt; property can be very useful to reposition the image inside the parent box.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;object position&lt;/em&gt; property takes keyword values like; &lt;em&gt;top&lt;/em&gt;, &lt;em&gt;bottom&lt;/em&gt;, &lt;em&gt;left&lt;/em&gt;, &lt;em&gt;right&lt;/em&gt;, &lt;em&gt;center&lt;/em&gt;, and length units such as &lt;em&gt;px&lt;/em&gt;, &lt;em&gt;rem&lt;/em&gt;, and &lt;em&gt;em&lt;/em&gt; to position the image to a specific area within the parent box. It also takes % values to specify the position of the image relative to the parent &lt;em&gt;width&lt;/em&gt; and &lt;em&gt;height&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2726%2F0%2A6-TvfgmavIzfmfZs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2726%2F0%2A6-TvfgmavIzfmfZs.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section&amp;gt;
            &amp;lt;p&amp;gt;Click the button to re-position the image within it container&amp;lt;/p&amp;gt;
        &amp;lt;/section&amp;gt;
        &amp;lt;section class="container"&amp;gt;
            &amp;lt;aside class="bg-img"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/296851660-8ef8d6fc-49a8-40cd-bd99-cc1fc78f0020.jpg" alt="" id="image"&amp;gt;
            &amp;lt;/aside&amp;gt;

            &amp;lt;aside class="btn"&amp;gt;
                &amp;lt;button&amp;gt;Left Top&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;Right Bottom&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;50% 50%&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;25% 75%&amp;lt;/button&amp;gt;
                &amp;lt;button&amp;gt;100px&amp;lt;/button&amp;gt;
            &amp;lt;/aside&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  main {
            width: 100vw;
            height: 100svh;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .container {
            width: 400px;
            height: 250px;
            border: 4px solid rgb(2, 93, 129);
        }

        .btn {
            display: flex;
            height: fit-content;

        }

        button {
            width: 100%;
            line-height: 40px;
            background: rgb(149, 221, 250);
            border: 4px solid rgb(2, 93, 129);
            transition: background 0.5s linear;
        }
        button:hover {
            background-color: rgb(2, 93, 129));
        }
        button:active {
            box-shadow: inset 2px 2px 2px 2px rgba(0, 0, 0, 0.5);
        }

        .bg-img {
            height: 100%;
            background: rgb(149, 221, 250);
        }

        p {
            font-family: calibri;
            font-size: 18px;
            color: #8d8989;
        }

        .bg-img img {
            display: block;
            width: 100%;
            object-fit: none;
            object-position: left;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const image = document.querySelector('#image');

        const allButtons = document.querySelectorAll('button');

        allButtons.forEach((button, idx)=&amp;gt; {
            if(idx === 0) {
                button.addEventListener('click', (e)=&amp;gt;{
                    image.style.objectPosition = 'left top';
                })
            }

            if(idx === 1) {
                button.addEventListener('click', (e)=&amp;gt;{
                    image.style.objectPosition = 'right bottom';
                })
            }

            if(idx === 2) {
                button.addEventListener('click', (e)=&amp;gt;{
                    image.style.objectPosition = '50% 50%';
                })
            }

            if(idx === 3) {
                button.addEventListener('click', (e)=&amp;gt;{
                    image.style.objectPosition = '25% 75%';
                })
            }

            if(idx === 4) {
                button.addEventListener('click', (e)=&amp;gt;{
                    image.style.objectPosition = '100px';
                })
            }
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/zYbZOey?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simplify the process of converting &lt;a href="https://www.lambdatest.com/free-online-tools/json-to-yaml?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JSON to YAML&lt;/a&gt; with our online JSON to YAML converter tool to convert JSON files to YAML. No sign-up required. Get started now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Tips for Centering an Image in CSS
&lt;/h2&gt;

&lt;p&gt;CSS properties play a huge role in how images are centered and positioned around the webpage or within the element container. However, other factors such as the image container, image size, scaling, and image data determine how images are positioned on the web page.&lt;/p&gt;

&lt;p&gt;In this section, we’ll explain tips for centering an image in CSS within the containing element to create a structured and responsive layout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Image Container
&lt;/h2&gt;

&lt;p&gt;The image container plays a huge role in how images are centered on the web. The image container is simply the direct parent element that the &lt;em&gt;&amp;lt; img /&amp;gt;&lt;/em&gt; tag is nested in. For example, if you create a &lt;em&gt;&amp;lt; div &amp;gt;&lt;/em&gt; tag and place an &lt;em&gt;&amp;lt; img /&amp;gt;&lt;/em&gt; tag inside the &lt;em&gt;&amp;lt; div &amp;gt;&lt;/em&gt; tag, the &lt;em&gt;&amp;lt; div &amp;gt;&lt;/em&gt; is the parent element (image container), not the &amp;lt; img /&amp;gt; tag itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AtxlkAj0R266v-bz_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AtxlkAj0R266v-bz_.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, if you import the image with the &lt;em&gt;background-image&lt;/em&gt; CSS property on a &lt;em&gt;&amp;lt; div &amp;gt;&lt;/em&gt; tag. The &lt;em&gt;&amp;lt; div &amp;gt;&lt;/em&gt; that received the image as its background image is the image container.&lt;/p&gt;

&lt;p&gt;From the image above, we have two image containers, the two image containers are centered around the page using flexbox. However, the second image on the right is centered within its container using the &lt;em&gt;background-position&lt;/em&gt; property.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;lt;html lang="en"&amp;gt;
&amp;amp;lt;head&amp;gt;
    &amp;amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;amp;lt;title&amp;gt;Document&amp;amp;lt;/title&amp;gt;
&amp;amp;lt;/head&amp;gt;

&amp;amp;lt;body&amp;gt;
    &amp;amp;lt;main&amp;gt;
        &amp;amp;lt;section&amp;gt;
            &amp;amp;lt;aside class="card one"&amp;gt;
                &amp;amp;lt;div&amp;gt;
                    &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297184236-b744205c-36be-4162-a1d9-e390102dd462.jpg" alt=""&amp;gt;
                &amp;amp;lt;/div&amp;gt;
                &amp;amp;lt;p&amp;gt;using the img tag&amp;amp;lt;/p&amp;gt;
            &amp;amp;lt;/aside&amp;gt;

            &amp;amp;lt;aside class="card two"&amp;gt;
                &amp;amp;lt;div&amp;gt;
     &amp;amp;lt;!-- we are using the background-image property to import image --&amp;gt;
                &amp;amp;lt;/div&amp;gt;
                &amp;amp;lt;p&amp;gt;using the background-image property&amp;amp;lt;/p&amp;gt;
            &amp;amp;lt;/aside&amp;gt;
        &amp;amp;lt;/section&amp;gt;
    &amp;amp;lt;/main&amp;gt;
&amp;amp;lt;/body&amp;gt;
&amp;amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     *, *::after, *::before {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        main {
            width: 100vw;
            height: 100svh;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        section {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 20px;
        }

        .card {
            width: 300px;
            height: 300px;
        }

        img {
            width: 100%;
        }

        div {
            border: 2px solid #8d8989;
            width: 100%;
        }

        .card.two div {
            height: 300px;
            width: 300px;

            background-image: url("https://user-images.githubusercontent.com/78242022/297184236-b744205c-36be-4162-a1d9-e390102dd462.jpg");
            background-repeat: no-repeat;
            background-size: 200px 100px;
            background-position: center;

        }

        p {
            font-family: calibri;
            font-size: 18px;
            color: #8d8989;
        }

        @media screen and (max-width: 650px) {
            section {
            margin-top: 2em; 
            flex-direction: column;
        }

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

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simplify SQL data representation with our user-friendly &lt;a href="https://www.lambdatest.com/free-online-tools/sql-to-xml?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;SQL to XML&lt;/a&gt; Converter. Convert query results to XML format effortlessly and enhance data interoperability.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This CSS code includes styling for a responsive layout with flexbox and card dimensions. Each card is styled as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Card one:&lt;/strong&gt; From the first card element, the &lt;em&gt;width&lt;/em&gt; and &lt;em&gt;height *are set to *300px,&lt;/em&gt; respectively, and inside this element, we nested a &lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; tag and set the &lt;em&gt;width&lt;/em&gt; to &lt;em&gt;100%&lt;/em&gt; to inherit the default size of the element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Card two&lt;/strong&gt;: From the second element, the &lt;em&gt;width *and *height *are set to *300px,&lt;/em&gt; respectively. With the &lt;em&gt;background-image&lt;/em&gt; property, we specify an image and set the size using the &lt;em&gt;background-size&lt;/em&gt; property. The image is then centered with the &lt;em&gt;background-position&lt;/em&gt; property.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The containing element is essential and plays a huge role in centering elements on the web when proper sizing is implemented.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/BabWjNq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Sizing Images
&lt;/h2&gt;

&lt;p&gt;Images come in large file sizes, making it impossible to center on the web page. Unsized images can lead to unwanted scrollbars and break the page layout. Most images pop out of the element box when it is not size.&lt;/p&gt;

&lt;p&gt;The essence of sizing or &lt;a href="https://www.lambdatest.com/blog/css-image-resizing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;resizing images in CSS&lt;/a&gt; is to ensure consistency across multiple and different elements and for images to take the shape of an element or layout.&lt;br&gt;
CSS itself does not directly handle the content of images, but it does provide properties and rules that allow you to control the size of images within HTML documents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ADMNxrLkiLCnuurHS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ADMNxrLkiLCnuurHS.png" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;em&gt;width, max-width, min-width, height, min-height,&lt;/em&gt; and &lt;em&gt;max-height&lt;/em&gt; properties, we can resize images with CSS to fit within the image container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2730%2F0%2Aj_8bDX24UI4TRacW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2730%2F0%2Aj_8bDX24UI4TRacW.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output above, each image is resized to fit into the container of the image element, making it easy to position around the webpage and within the image container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;lt;html lang="en"&amp;gt;
&amp;amp;lt;head&amp;gt;
    &amp;amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" /&amp;gt;
&amp;amp;lt;/head&amp;gt;

&amp;amp;lt;body&amp;gt;
    &amp;amp;lt;main&amp;gt;
        &amp;amp;lt;section&amp;gt;
            &amp;amp;lt;aside class="card card-one"&amp;gt;
                &amp;amp;lt;div&amp;gt;
                    &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297385859-05ce3e2a-d20d-4390-a4eb-d2aea03ceb87.jpg" alt="" class="head-img"&amp;gt;
                &amp;amp;lt;/div&amp;gt;
                &amp;amp;lt;div&amp;gt;
                    &amp;amp;lt;h1&amp;gt;New York&amp;amp;lt;/h1&amp;gt;
                    &amp;amp;lt;p class="street para"&amp;gt;Street&amp;amp;lt;/p&amp;gt;
                    &amp;amp;lt;p class="save para"&amp;gt;Travel now&amp;amp;lt;/p&amp;gt;
                    &amp;amp;lt;div class="circle-dots"&amp;gt;
                        &amp;amp;lt;span class="circle circle-red"&amp;gt;&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;span class="circle circle-blue"&amp;gt;&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;span class="circle circle-orange"&amp;gt;&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;span class="circle circle-purple"&amp;gt;&amp;amp;lt;/span&amp;gt;
                    &amp;amp;lt;/div&amp;gt;
                    &amp;amp;lt;div&amp;gt;
                        &amp;amp;lt;button class="btn"&amp;gt;
                            &amp;amp;lt;i class="fa-solid fa-cart-shopping"&amp;gt;&amp;amp;lt;/i&amp;gt;
                            &amp;amp;lt;span&amp;gt;add to cart&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;/button&amp;gt;
                    &amp;amp;lt;/div&amp;gt;
                &amp;amp;lt;/div&amp;gt;
            &amp;amp;lt;/aside&amp;gt;

            &amp;amp;lt;aside class="card card-two"&amp;gt;
                &amp;amp;lt;div&amp;gt;
                    &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297184256-d7d58744-1082-4567-9d1e-3f9569894783.jpg" alt="" class="head-img"&amp;gt;
                &amp;amp;lt;/div&amp;gt;
                &amp;amp;lt;div&amp;gt;
                    &amp;amp;lt;h1&amp;gt;New York&amp;amp;lt;/h1&amp;gt;
                    &amp;amp;lt;p class="street para"&amp;gt;Street&amp;amp;lt;/p&amp;gt;
                    &amp;amp;lt;p class="save para"&amp;gt;take a trip&amp;amp;lt;/p&amp;gt;
                    &amp;amp;lt;div class="circle-dots"&amp;gt;
                        &amp;amp;lt;span class="circle circle-red"&amp;gt;&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;span class="circle circle-blue"&amp;gt;&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;span class="circle circle-orange"&amp;gt;&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;span class="circle circle-purple"&amp;gt;&amp;amp;lt;/span&amp;gt;
                    &amp;amp;lt;/div&amp;gt;
                    &amp;amp;lt;div&amp;gt;
                        &amp;amp;lt;button class="btn"&amp;gt;
                            &amp;amp;lt;i class="fa-solid fa-cart-shopping"&amp;gt;&amp;amp;lt;/i&amp;gt;
                            &amp;amp;lt;span&amp;gt;add to cart&amp;amp;lt;/span&amp;gt;
                        &amp;amp;lt;/button&amp;gt;
                    &amp;amp;lt;/div&amp;gt;
                &amp;amp;lt;/div&amp;gt;
            &amp;amp;lt;/aside&amp;gt;
        &amp;amp;lt;/section&amp;gt;
    &amp;amp;lt;/main&amp;gt;
&amp;amp;lt;/body&amp;gt;
&amp;amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    *, *::after, *::before {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }

    body {
        background-color: rgb(122, 12, 224);
    }

    main {
        width: 100vw;
        height: 100svh;
    }

    section {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        gap: 20px;
    }

    .card {
        width: 200px;
        background-color: #fff;
        padding: .5em;
        border-radius: 5px;
    }

    .card .head-img {
        width: 100%;
        height: 200px;
        border-radius: 5px;
        object-fit: cover;
    }

    .card-two .head-img {
        border-radius: 100px;
    }

    h1 {
        font-family: calibri;
        margin: 0.2em 0;
    }

    .para {
        font-family: calibri;
        font-size: 18px;
        color: #8d8989;
    }

    .street {
        color: black;
    }

    .circle-dots {
        display: flex;
    }

    .circle {
        border-radius: 100px;
        width: 15px;
        height: 15px;
        margin: .2em .2em;
    }


    .circle-red {
        background-color: red;
    }
    .circle-blue {
        background-color: blue;
    }
    .circle-orange {
        background-color: orange;
    }
    .circle-purple {
        background-color: purple;
    }

    .btn {
        margin-top: .9em;
        background-color: black;
        color: white;
        border-radius: 5px;
        width: 100%;
        padding: .5em;
        border: none;
        cursor: pointer;
        transition: all 0.5s linear;
    }

    .btn:hover {
        background-color: wheat;
        color: black;
    }

    .btn:active {
        transform: translateY(4px);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;From the code above, the &lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; element with a class of &lt;em&gt;head-img&lt;/em&gt; is set to &lt;em&gt;100%&lt;/em&gt; width and &lt;em&gt;200px&lt;/em&gt; height. This enables each image to fit into the parent container. However, the second &lt;em&gt;&amp;lt; img &amp;gt;&lt;/em&gt; is set to a &lt;em&gt;border-radius&lt;/em&gt; of &lt;em&gt;100px&lt;/em&gt; to round the image to a circle.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/OJqpOzx?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simplify your data export process with our efficient &lt;a href="https://www.lambdatest.com/free-online-tools/sql-to-csv?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;SQL to CSV&lt;/a&gt; Converter. Convert SQL queries to CSV format seamlessly and unlock data versatility. Try it now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Scaling Images
&lt;/h2&gt;

&lt;p&gt;The best way to scale images in CSS is by sizing, but sometimes this is not enough, especially when the image aspect ratio, resolution, or orientation does not correspond to the width and height of the image-container. The image can easily become distorted or compressed.&lt;/p&gt;

&lt;p&gt;This is not good for readability purposes as visitors might find it difficult to read the content on the image.&lt;/p&gt;

&lt;p&gt;To fix this, CSS provides properties such as &lt;em&gt;object-fit, margin: auto, aspect-ratio, background-size, flex-grow, *and *flex-basis.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These properties are very useful for creating and developing responsive layouts. This ensures images are responsive relative to the device or screen resolution that loads the image.&lt;/p&gt;

&lt;p&gt;When the aspect ratio of images is maintained across different viewports, it prevents distortion and leads to more fitting looks on the webpage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Acy_E6Vc8adLnDCo6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Acy_E6Vc8adLnDCo6.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;lt;html lang="en"&amp;gt;
&amp;amp;lt;head&amp;gt;
    &amp;amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;

&amp;amp;lt;/head&amp;gt;

&amp;amp;lt;body&amp;gt;
    &amp;amp;lt;main&amp;gt;
        &amp;amp;lt;section class="viewport view-1"&amp;gt;
            &amp;amp;lt;aside&amp;gt;
                &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297184256-d7d58744-1082-4567-9d1e-3f9569894783.jpg" alt=""&amp;gt;
            &amp;amp;lt;/aside&amp;gt;
        &amp;amp;lt;/section&amp;gt;

        &amp;amp;lt;section class="viewport view-2"&amp;gt;
            &amp;amp;lt;aside&amp;gt;
                &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297184256-d7d58744-1082-4567-9d1e-3f9569894783.jpg" alt=""&amp;gt;
            &amp;amp;lt;/aside&amp;gt;
        &amp;amp;lt;/section&amp;gt;

        &amp;amp;lt;section class="viewport view-3"&amp;gt;
            &amp;amp;lt;aside&amp;gt;
                &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297184256-d7d58744-1082-4567-9d1e-3f9569894783.jpg" alt=""&amp;gt;
            &amp;amp;lt;/aside&amp;gt;
        &amp;amp;lt;/section&amp;gt;

        &amp;amp;lt;section class="viewport view-4"&amp;gt;
            &amp;amp;lt;aside&amp;gt;
                &amp;amp;lt;img src="https://user-images.githubusercontent.com/78242022/297184256-d7d58744-1082-4567-9d1e-3f9569894783.jpg" alt=""&amp;gt;
            &amp;amp;lt;/aside&amp;gt;
        &amp;amp;lt;/section&amp;gt;
    &amp;amp;lt;/main&amp;gt;
&amp;amp;lt;/body&amp;gt;
&amp;amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    *, *::after, *::before {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }

    body {
        background-color: rgb(43, 43, 255);
    }

    .viewport {
        width: 100%;
        height: 100svh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .viewport aside {
        width: 50%;
        height: 400px;
        padding: 20px;
        background-color: rgba(240, 248, 255, 0.5);
        border-radius: 10px;
        border: 1px solid #fff;

        backdrop-filter: blur(10px);
        -moz-backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .viewport img {
        width: 100%;
        height: 100%;
        border-radius: 10px;
    }

    .view-1 img {
        object-fit: cover;
    }

    .view-2 img {
        object-fit: contain;
    }

    .view-3 aside {
        aspect-ratio: 16 / 9;
        flex-grow: 1;
    }

    .view-3 img {
        object-fit: cover;
    }


    .view-4 aside {
        aspect-ratio: 1 / 1;
        width: 30%;
    }

    .view-4 img {
        object-fit: cover;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code above, &lt;em&gt;object-fit cover&lt;/em&gt;, &lt;em&gt;object-fit contain,&lt;/em&gt; and &lt;em&gt;aspect-ratio *property is used to set the four *&amp;lt; img &amp;gt;&lt;/em&gt; elements to scale relative to the parent element, creating a responsive layout across different viewports.&lt;/p&gt;

&lt;p&gt;For example, the images below show a good use case using the LT Browser. The scaled images display responsively across different screen sizes for better navigation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LT Browser&lt;/a&gt; is a free, Chromium-based web browser specifically for web developers. It excels at &lt;a href="https://www.lambdatest.com/learning-hub/responsive-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;responsive testing&lt;/a&gt; and &lt;a href="https://www.lambdatest.com/learning-hub/debugging?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;debugging&lt;/a&gt; websites and web applications across different screen sizes. This makes it an ideal tool for ensuring your image centering in CSS works flawlessly on all platforms.&lt;/p&gt;

&lt;p&gt;Loaded with 53+ pre-installed device viewports, LT Browser includes popular mobiles, tablets, and desktops. It allows you to see how your website reacts across various screen sizes and resolutions. This lets you instantly check if your CSS image centering adapts properly. You can identify issues like images overflowing the content area, cropped unexpectedly, or inconsistent spacing on different devices.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ApxlcxLsDzOYbVu6P.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ApxlcxLsDzOYbVu6P.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AP8qYASfssSZEENmd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AP8qYASfssSZEENmd.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A34iw82UeFkTWa8Ld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A34iw82UeFkTWa8Ld.png" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Get to know the different features that LT Browsers offers. Check out the tutorial below:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/rqFeuaZ-wAY"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Catch up on the latest testing tutorials around &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, and more. 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=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; for quick updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Image Data/Metadata
&lt;/h2&gt;

&lt;p&gt;Image data refers to the data that makes up the content of the actual image, such as pixel information, size, orientation, resolution, RGB color mode, etc. The image data determines how the image in the browser is rendered and how it will be affected or positioned with CSS styling.&lt;/p&gt;

&lt;p&gt;However, in the content of the image metadata, which differs from the image data, the image metadata deals with the extra text information that describes what the image is about. For example the name of the image, the date and time it was taken, and the name of the software or camera used to create the image.&lt;/p&gt;

&lt;p&gt;The image metadata is very useful and can improve search engine optimization, making images easy to discover and providing accurate details to protect an image against copyright infringement.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Want to convert SCSS to clean, concise CSS? Convert &lt;a href="https://www.lambdatest.com/free-online-tools/scss-to-css?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;SCSS to CSS&lt;/a&gt; like a pro with our intuitive online tool. Get clean, readable code instantly. Start converting today!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Browser Compatibility
&lt;/h2&gt;

&lt;p&gt;Centering images on the web heavily relies on CSS. It provides properties for styling and controlling the appearance and positioning of images on the web. However, due to browser incompatibility with some CSS properties, certain browsers might not load some properties, leading to unexpected image breaking.&lt;/p&gt;

&lt;p&gt;To check and fix this, we can use AI-powered test orchestration and execution platforms like LambdaTest to test how the images on our websites are centered across multiple browsers such as Chrome, Firefox, Opera, Safari, Brave, etc. This platform offers an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of real desktop and mobile environments. &lt;a href="https://www.lambdatest.com/online-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_13&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cross browser testing&lt;/a&gt; gives visual feedback on how web elements render on the web pages. This makes it easy to visually test and debug web elements on the web page.&lt;/p&gt;

&lt;p&gt;Also, CSS properties browser support can be checked via CanIUse to understand when and how to implement such properties for better optimization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQUatMZtHXc3yjfc2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQUatMZtHXc3yjfc2.png" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, the &lt;em&gt;background-filter&lt;/em&gt; used in the last example is partially supported in Safari and requires the use of &lt;em&gt;-webkit-&lt;/em&gt; prefix for rendering the &lt;em&gt;background-filter&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2146%2F0%2AnIO5KEHq5Wjk9GMI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2146%2F0%2AnIO5KEHq5Wjk9GMI.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ensuring CSS properties used in centering images are well-supported or prefixed can help prevent unwanted or poor image rendering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this guide, we explained how to center images in CSS and its significance.&lt;/p&gt;

&lt;p&gt;We also discussed two techniques of centering an image in CSS: within a page and in a container.&lt;/p&gt;

&lt;p&gt;In the technique for centering an image in CSS within the web page, we explained using properties like &lt;em&gt;flexbox, grid, margin: auto, position&lt;/em&gt; properties, and &lt;em&gt;transform: translate&lt;/em&gt; property and how they can be implemented in centering images around the web page.&lt;/p&gt;

&lt;p&gt;And in the technique for centering images in CSS within its container, we highlight the use of &lt;em&gt;background-position&lt;/em&gt; and &lt;em&gt;object-position&lt;/em&gt; properties as a method for positioning images within the element container.&lt;/p&gt;

&lt;p&gt;We also touched upon other important factors that affect centering an image in CSS, such as the image container, sizing, scaling, and browser compatibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I center an image in CSS?
&lt;/h3&gt;

&lt;p&gt;For horizontal centering, wrap your image in a &lt;em&gt;div&lt;/em&gt; and set &lt;em&gt;text-align: center&lt;/em&gt; for the &lt;em&gt;div&lt;/em&gt;. Alternatively, use &lt;em&gt;margin: 0&lt;/em&gt; auto on the image itself, but remember to set a width if needed. The flexbox approach involves setting the container’s &lt;em&gt;display&lt;/em&gt; to &lt;em&gt;flex&lt;/em&gt; and &lt;em&gt;justify-content&lt;/em&gt; to &lt;em&gt;center&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to position an image in CSS?
&lt;/h3&gt;

&lt;p&gt;The test automation pyramid is a graphical strategy model for automating software testing. The model divides testing types into three layers based on the return on investment (ROI) provided by automating that specific type.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I center an absolute image in CSS?
&lt;/h3&gt;

&lt;p&gt;To center an absolute image horizontally, set &lt;em&gt;position: absolute&lt;/em&gt;, &lt;em&gt;left: 50%&lt;/em&gt;, and transform: &lt;em&gt;translateX(-50%)&lt;/em&gt;. For vertical centering, add &lt;em&gt;top: 50%&lt;/em&gt; and &lt;em&gt;transform: translateY(-50%)&lt;/em&gt;. Remember, absolute positioning removes the image from the normal document flow, so it won’t interact with other elements as expected.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building Accessible Carousels: A Step-By-Step Guide</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Mon, 11 Mar 2024 12:03:19 +0000</pubDate>
      <link>https://forem.com/testmuai/building-accessible-carousels-a-step-by-step-guide-74d</link>
      <guid>https://forem.com/testmuai/building-accessible-carousels-a-step-by-step-guide-74d</guid>
      <description>&lt;p&gt;Carousels are effective in conveying pieces of information in a concise format on the web page. Many organizations find value in using carousels to showcase their product offerings. This feature has proven to be a valuable asset for driving conversions and enhancing user engagement.&lt;/p&gt;

&lt;p&gt;Despite being helpful and a great fit for everyday users, carousels come with a lot of accessibility issues, which prevent impaired users from interacting with them. Therefore, it becomes imperative to create accessible carousels that are truly beneficial and inclusive for all users. It’s an investment that pays off in terms of ethics, usability, and overall website performance.&lt;/p&gt;

&lt;p&gt;In this article, we will dive deep into accessible carousels, why to use them, the components of carousels, and how to build accessible carousels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test native, hybrid, and web apps on any mobile OS with our free &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online emulator Android&lt;/a&gt; . Sign up to optimize app performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What are Carousels?
&lt;/h2&gt;

&lt;p&gt;A carousel is a group of individual elements, where each element is called a slide, and each slide is set to overflow horizontally across its containing element.&lt;/p&gt;

&lt;p&gt;Ac*cording to beta testing of the multi-destination function on the carousel by X Business, they saw* a 20% increase in click-through rate across single posts of carousel assets and a 25% lift in click-through rate for campaigns that optimize for site visit conversion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYOQmTttwsBemPTP6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYOQmTttwsBemPTP6.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, the Airbnb website below contains four elements with header images. Each image within the header serves as a slide.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ALNgbKRAf5Q9uzwtg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ALNgbKRAf5Q9uzwtg.png" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A slide in a carousel moves horizontally in sequential order; each slide rotates one at a time and hides to provide space for the next slide.&lt;/p&gt;

&lt;p&gt;Once again, from the Airbnb website, each slide moves horizontally when the slider control is clicked on, revealing the next slide.&lt;/p&gt;

&lt;p&gt;Users can directly interact with each slide by using the carousel controls. These controls enable the user to move the slides back and forth. Some carousels enable the keyboard or drag to scroll to move each slide within its slide container.&lt;/p&gt;

&lt;p&gt;The carousel typically displays once the page loads, while the “slide picker controls” indicate which slide is displayed.&lt;/p&gt;

&lt;p&gt;We can also see the same method replicated on the Motorola website, where each slide showcases the organization’s products as an ad. These types of carousels are banner carousels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test native, hybrid, and web apps on any mobile OS with our free &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online Android emulator&lt;/a&gt;. Sign up to optimize app performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Components of Carousels
&lt;/h2&gt;

&lt;p&gt;Before discussing the importance of accessible carousels, let’s explore different carousel components. Carousel slides are content in the form of a slide. Each slide displays different content and loops one after the other.&lt;/p&gt;

&lt;p&gt;To ensure a good user experience, carousels typically have controls that enable users to navigate around the carousel content, known as slides. The controls also indicate which side (content) is currently on display.&lt;/p&gt;

&lt;p&gt;The following examples are controls or slide controls that can be implemented when creating a carousel element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AG_xJwRkw6uGscUvc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AG_xJwRkw6uGscUvc.png" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Previous slide controls:&lt;/strong&gt; This is a button element with a left arrow icon for navigating the slides back in sequence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Next slide controls:&lt;/strong&gt; This is a button element with a right arrow icon for navigating the slides forward in sequence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slide picker controls:&lt;/strong&gt; These are small groups of button elements, usually at the base of the carousel. These buttons mainly do two things, one of which is to indicate which slides are currently on display and to navigate to a specific slide without using the slide controls.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pause/play controls:&lt;/strong&gt; This control button controls the play and pause state of the carousel slides. This is mainly seen in the carousel displayed when the page loads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slide:&lt;/strong&gt; A slide is the individual items that displays in sequence. However, a slide is not a control but can be implemented as a control for drag events, where users can drag a slide to review the next slide.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Toyota landing page shows how to trigger the animation play state using the play and pause button.&lt;/p&gt;

&lt;p&gt;To improve user interaction, keyboards such as spacebars, taps, and arrow keys can be a good control source.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spacebar:&lt;/strong&gt; The space bar control works when the pause/play control is implemented. It serves as an alternative to pause/play control.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, the MasterClass website shows how to pause and play the slide animation with either the spacebar or the pause/play control.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Array keys:&lt;/strong&gt; The left and right arrow keys on the keyboard can be handy as an alternative to the “previous slide controls” and “next slide control”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tap and Shift keys:&lt;/strong&gt; The tap or shift + tab key can loop or navigate between slides in sequence.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test native, hybrid, and web apps on any mobile OS with our free &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android online emulator&lt;/a&gt;. Sign up to optimize app performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why are Accessible Carousels Needed?
&lt;/h2&gt;

&lt;p&gt;Accessible carousels are very much needed to provide instructions to visually impaired users to enable them to navigate carousel elements on the web page. According to WHO, almost 2.2 billion have a visual impairment in some way, making it difficult for people with visual impairment to access the web.&lt;/p&gt;

&lt;p&gt;Accessible carousels are needed for multiple reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;They enable visually impaired users to identify components/controls that make up the carousel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assistive technology tools such as screen readers, text-to-speech, and refreshable braille display software reads aria Roles, States, and Properties as audible text to visually impaired users. This helps visually impaired users understand how the carousel works and how to use it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accessible carousels are also necessary for compliance with accessibility standards such as WCAG 2.0 and Section 508.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With accessible carousels, visually impaired users can navigate carousel components using voice input software and keyboard navigation with the help of accessibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Carousel content can be paused with carousel control by users distracted by frequent movement of the content to enable them to listen to carousel content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visual-impaired users can determine the state of the carousel if it’s pressed, disabled, checked, or hidden.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Accessible carousels generally provide good semantics in the form of audio/speech for visually impaired users. This helps to determine the landmark area the carousel occupies and its role, its content, and how to navigate it on the web page.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Check out the best &lt;a href="https://www.lambdatest.com/blog/ios-emulators-for-pc/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;iOS emulators for PC&lt;/a&gt; you should consider for mobile application testing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Are Carousels Good for Accessibility?
&lt;/h2&gt;

&lt;p&gt;Despite being implemented across multiple sites by web developers, Carousels have numerous associated issues, which we will split into two parts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interactivity
&lt;/h2&gt;

&lt;p&gt;Carousels have unpleasant user experiences, as users rarely interact with them. This might be due to a lack of understanding of interacting with carousels.&lt;/p&gt;

&lt;p&gt;A study based on Google Analytics Event recorded the number of interactivity. The report states the percentage of visitors who clicked on a carousel feature is 1%, with the first feature getting the highest clicks or interactivity. In contrast, other features have to share the same or no interaction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AUzB1h9C_-vZexis2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AUzB1h9C_-vZexis2.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows click distribution by position. Position 1 is shown to take the highest number, while other positions share the same proposition evenly. This is not good for sites with multiple carousels, as the chances of them being interacted with are low or there is no interaction.&lt;/p&gt;

&lt;p&gt;However, to increase the chance of interactivity,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Consider reducing the number of slides to a maximum of four.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Captivating headline titles and images can significantly impact click-through rates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Content should contain a single idea as it helps users understand what each slide presents.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since the first slide gets the most attention, the most important slide should be implemented first to encourage user click-through.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A comprehensive &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt; tutorial that covers what E2E testing is, its importance, and how to perform it.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Accessibility
&lt;/h2&gt;

&lt;p&gt;Accessible carousels involve ensuring all users can access the content on each slide and navigate each slide via the slider controls.&lt;/p&gt;

&lt;p&gt;However, for visually impaired users, screen-readers, and text-to-speech software (assistive technology tools) are relied upon to report the right content or information to the users. For instance, animated slides with pause/play control can display multiple shows within a slide without proper use of WAI-ARIA Roles, States, and Properties. The screen reader can report this as multiple slides instead of showing within a slide or as a plain HTML tag.&lt;/p&gt;

&lt;p&gt;Let’s take the Toyota homepage as an example.&lt;/p&gt;

&lt;p&gt;From the Toyota homepage, the first slide has two shows that display before the next slide is displayed. At the bottom left corner is a pause /play control for pausing or playing each show within the slide. Without proper WAI-ARIA for labeling, this might not get the right accessible result from screen readers.&lt;/p&gt;

&lt;p&gt;Accessibility plays an excellent role for visually impaired users, and assistive technology tools help convey digital content on the web to visually impaired users by speech synthesis (Text-to-Speech) TTS. For example, when a user clicks or interacts with web elements, the screen readers extract the content and report it as an audible speech.&lt;/p&gt;

&lt;p&gt;For assistive technology tools to be effective or detect content, several factors have to be implemented, such as the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Alternative text:&lt;/strong&gt; Mainly referred to as &lt;em&gt;alt&lt;/em&gt; text, alternative text is HTML attributes used to write descriptive text to describe the image or content provided within the HTML tag. This attribute is used for content such as images, videos, audio, logos, and web icons. They are helpful for Google search engines and assistive technology tools like screen readers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.example.com%2Fimages%2Fsky" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.example.com%2Fimages%2Fsky" alt="Blue Sky" width="800" height="400"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Semantic markup:&lt;/strong&gt; Semantic markup is HTML tags used to describe the role of the content on the page. This enables web browser format and renders content currently on the web page. Screen readers can also detect semantic markup.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, when a user interacts with a button on a page, screen readers can produce audio feedback indicating the element is a button that can be clicked.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;h1&amp;gt;This is a top level 1 heading&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;This is a paragraph text&amp;lt;/p&amp;gt;
&amp;lt;button&amp;gt;Click here &amp;lt;/button&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;em&gt;&amp;lt; h1 &amp;gt;&lt;/em&gt; element shows that the content inside the tag should be treated as a level 1 heading, while the &lt;em&gt;&amp;lt; p &amp;gt;&lt;/em&gt; tag shows that the content inside it should be treated as a paragraph text. The &lt;em&gt;&amp;lt; button &amp;gt;&lt;/em&gt; element shows that this is a clickable button element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Captions:&lt;/strong&gt; Unlike alternative text, captions are displayed directly on the web page. Caption provides a descriptive text that explains what the provided content is about, especially for images. &lt;em&gt;&amp;lt; figcaptions &amp;gt;&lt;/em&gt; are used to provide captions in HTML documents. Captions can be very useful for hearing-impaired users.&lt;/p&gt;


    &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.example.com%2Fimages%2Fsky" alt="Blue Sky" width="800" height="400"&gt;A beautify picture of blue sky
    
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the next section, we will see the role of WAI-ARIA in building accessible carousels.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Role of WAI-ARIA in Creating Accessible Carousels
&lt;/h2&gt;

&lt;p&gt;The WAI-ARIA, which stands for Web Accessibility Initiative — Accessible Rich Internet Applications, is a specification developed by W3C to provide semantic meaning to assistive technology tools such as screen readers for ensuring content on the web are interpreted the way they function and appear on the web.&lt;/p&gt;

&lt;p&gt;For example, visually impaired users cannot see the carousel on the web or interact with the carousel directly, so the WAI-ARIA Roles, States, and Properties are used by developers to provide additional text based information on the HTML tags that describe what the carousel actually means or how the carousel controls functions.&lt;/p&gt;

&lt;p&gt;This enables screen readers to read WAI-ARIA Roles, States, and Properties as audible speech back to visually impaired users as it enables them to navigate and use the website the way it was intended by the developer.&lt;/p&gt;

&lt;p&gt;When the HTML document is loaded on the &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; by the User Agent, it creates a parallel structure called an accessibility tree, which is made up of accessibility objects. The accessible objects provide information on the HTML markup based on the Roles, States, and Properties of WAI-ARIA.&lt;/p&gt;

&lt;p&gt;Following are the WAI-ARIA Roles, States, and Properties that can be implemented to create accessible carousels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Roles:&lt;/strong&gt; The Role defines what the element is meant to do. For example, in a carousel slider, we can add a &lt;em&gt;role=”main”&lt;/em&gt; on the carousel-container, indicating that the specified element should be read as the main content of the carousel by screen readers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;States:&lt;/strong&gt; The State defines the current condition of the element. For example, we can add a &lt;em&gt;aria-disabled&lt;/em&gt; to a disabled button to inform the screen reader to read it as a disabled button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Properties: **The Properties provide more descriptive information about the element or content on the web page for screen readers. For example, the *aria-describedby&lt;/em&gt; can be used to describe the content of the carousel slides for screen readers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember that the Roles, States, and Properties are meant to be read as audible speech and do not have or add any functionality to the carousel or web elements.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on real iOS and Android &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;device clouds for mobile app testing&lt;/a&gt;. LambdaTest is a convenient, cost-effective and centralised solution for running realtime and Automated test on real device cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Techniques to Build Accessible Carousels
&lt;/h2&gt;

&lt;p&gt;Several crucial steps are important when building an accessible carousel. This step ensures that all carousel components are accessible, making it easy for visually impaired users to navigate.&lt;/p&gt;

&lt;p&gt;How a carousel is structured, or functions should not prevent it from being accessible. The following techniques illustrate how to create accessible carousels.&lt;/p&gt;

&lt;h2&gt;
  
  
  Auto-Rotation
&lt;/h2&gt;

&lt;p&gt;Auto-rotation carousels are very common in websites today. This type of carousel can also be called a banner carousel, mainly used to display ads that run as soon as the page loads and continues to auto-rotate.&lt;/p&gt;

&lt;p&gt;To improve and make the auto-rotating carousel accessible, a few important steps must be taken.&lt;/p&gt;

&lt;p&gt;Auto-rotate may be distracting for people with cognitive impairments. A control button (pause/play button) can be implemented to pause the animation to enable the users to concentrate.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WAI-ARIA Roles, States, and Properties:&lt;/strong&gt; These should be implemented to indicate to screen readers that the carousel has an auto-rotation state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pause auto-rotation on hover:&lt;/strong&gt; Users need time to read content. Implementing pause animation on hover helps visually cognitively impaired users focus on interacting or listening to the carousels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on real iOS and Android devices hosted on the cloud. LambdaTest is a &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile testing platform with real devices&lt;/a&gt; for running realtime and Automated test on real device cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Visibility
&lt;/h2&gt;

&lt;p&gt;For visually impaired users, visibility means the carousel components are well labeled with the appropriate WAI-ARIA Roles, States, and Properties. This helps to improve the accessibility nature of the carousels.&lt;/p&gt;

&lt;p&gt;Here are other aspects that should be considered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hidden elements should have a WAI-ARIA state to indicate the element is hidden or disabled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Carousel components should be labeled according to their functions. This makes it easily accessible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Buttons with SVGs as content should be labeled and assigned an accessible role to make it accessible to visually impaired users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overflow content should be hidden to make it easy to navigate the carousels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All carousel components should be responsive and easy to navigate on mobile, tablet, and desktop.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Buttons, slides, slider picker controls, play/pause state buttons, and other carousel components should be implemented and labeled accordingly to make them accessible.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Structure, Semantic, and Labeling
&lt;/h2&gt;

&lt;p&gt;Websites require good structure and semantic tags to make websites responsive, SEO friendly, and easy to navigate. This is because browsers can quickly load and render well-structured and semantic websites on the screen.&lt;br&gt;
However, visually impaired users rely heavily on the accessibility of the WAI-ARIA Roles, States, and Properties to determine the structure and semantics of the websites.&lt;/p&gt;

&lt;p&gt;In this case, good use of WAI-ARIA should be implemented on semantic tags to let the users know which element holds the main carousel and which element serves as the control.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main role="main" aria-label="carousel container"&amp;gt;
        &amp;lt;button role="button" aria-label="backward"&amp;gt;&amp;lt;/button&amp;gt;

        &amp;lt;section role="region" aria-label="carousel"&amp;gt;
            &amp;lt;!-- Slides --&amp;gt;
        &amp;lt;/section&amp;gt;
        &amp;lt;button role="button" aria-label="forward"&amp;gt;&amp;lt;/button&amp;gt;
&amp;lt;/main&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Landmarks should be implemented to make sections or groups of elements on the page accessible. For example, the &lt;em&gt;main, aside, form, section, article,&lt;/em&gt; and &lt;em&gt;div&lt;/em&gt; elements can be assigned relevant landmarks that explicitly state their role in the element.&lt;/p&gt;

&lt;p&gt;The WAI-ARIA &lt;em&gt;role&lt;/em&gt; attribute serves as a way to provide landmarks on the element for accessibility purposes.&lt;/p&gt;

&lt;p&gt;Now, let’s see a hands-on demonstration of building accessible carousels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore seamless app &lt;a href="https://www.lambdatest.com/test-on-mobile-devices?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test device online&lt;/a&gt; on real mobile devices with our hassle-free solutions. Ensure optimal performance across real-world scenarios effortlessly.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Demonstration: Building Accessible Carousels
&lt;/h2&gt;

&lt;p&gt;In this blog section on accessible carousels, we will look at various kinds of carousels and how to implement them in your software projects regarding accessibility as specified in the previous examples. To demonstrate the creation of accessible carousels, we will take three &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;popular carousel examples&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Product Carousels
&lt;/h2&gt;

&lt;p&gt;Product carousels are one of the most common carousels and can be seen on major e-commerce platforms such as Amazon, eBay, Walmart, Best Buy, and Apple Store. They are beneficial in cases where collections or groups of products are to be displayed on the website for easy navigation by the users.&lt;/p&gt;

&lt;p&gt;Here is a simple use case from the Apple Store. Each product is grouped based on the product’s items.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ARnXvQ-KGD547_N2K.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ARnXvQ-KGD547_N2K.png" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A simple example below shows how to implement a group of product items as carousels.&lt;/p&gt;

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

&lt;p&gt;From the example above, the carousel contains nine images, each image split into three groups called view. Each view contains similar products.&lt;/p&gt;

&lt;p&gt;For example, the first view is a display of Apple HomePod, the next is a display of Apple AirPods, and the last is the Apple 15 display.&lt;/p&gt;

&lt;p&gt;This example is most useful when we want to display the same kinds of products or items simultaneously and enable users to navigate around different items from similar types in a roll.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="group"&amp;gt;
&amp;lt;main class="carousel" role="main" aria-label="carousel"&amp;gt;

    &amp;lt;button type="button" id="backward" class="btn disabled" role="button" aria-label="backward"&amp;gt;
        &amp;lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="30" height="30" class="main-grid-item-icon" fill="none"      stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"&amp;gt;
        &amp;lt;polyline points="15 18 9 12 15 6" /&amp;gt;
        &amp;lt;/svg&amp;gt;
    &amp;lt;/button&amp;gt;

    &amp;lt;section class="carousel-sub"&amp;gt;
    &amp;lt;!-- View 1 --&amp;gt;
    &amp;lt;section class="img-wrapper" id="view1"&amp;gt;
        &amp;lt;span role="img" aria-label="HomePod, AirPods, or select Beats product"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274978352-f0fc35e2-652b-428d-927f-09bf61805dbf.jpeg" alt="HomePod, AirPods, or select Beats product"&amp;gt;
        &amp;lt;/span&amp;gt;
        &amp;lt;span role="img" aria-label="HomePod - Midnight"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274980258-9f84204f-197f-4e0b-8c0e-5a9511f1db53.jpeg" alt="HomePod - Midnight"&amp;gt;
        &amp;lt;/span&amp;gt;
        &amp;lt;span role="img" aria-label="HomePod mini - Yellow"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274982370-6c49ff19-7f72-43f0-9592-1861a506fec2.jpeg" alt="HomePod mini - Yellow"&amp;gt;
        &amp;lt;/span&amp;gt;
    &amp;lt;/section&amp;gt;


    &amp;lt;!-- View 2 --&amp;gt;
    &amp;lt;section class="img-wrapper" id="view2"&amp;gt;
        &amp;lt;span role="img" aria-label="AirPods Max - Silver"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274973852-afb2d3d0-2748-4612-a07a-b0f583c9d9b7.jpeg" alt="AirPods Max - Silver"&amp;gt;
        &amp;lt;/span&amp;gt;

        &amp;lt;span role="img" aria-label="AirPods (3rd generation) with Lightning Charging Case"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274973882-7cef7964-66fd-470f-8d5b-e8b3837ffcc9.jpeg" alt=" AirPods (3rd generation) with Lightning Charging Case"&amp;gt;
        &amp;lt;/span&amp;gt;

        &amp;lt;span  role="img" aria-describedby="Beats Studio Buds + True Wireless Noise Cancelling Earphones in Transparent, with Beats logo, above convenient charging case.
TransparentBlack / GoldIvoryCosmic SilverCosmic Pink"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274973892-a5bdc3c6-ea67-46e2-b8cc-57f9a4f068a2.jpeg" alt="Beats Studio Buds + True Wireless Noise Cancelling Earphones in Transparent, with Beats logo, above convenient charging case.
TransparentBlack / GoldIvoryCosmic SilverCosmic Pink"&amp;gt;
        &amp;lt;/span&amp;gt;
    &amp;lt;/section&amp;gt;


    &amp;lt;!-- view 3 --&amp;gt;
    &amp;lt;section class="img-wrapper" id="view3"&amp;gt;
        &amp;lt;span role="img" aria-label="iPhone 15 Pro FineWoven Case with MagSafe - Taupe"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274990709-1e3c4882-778f-49bd-9814-b940648ea4eb.jpeg" alt="iPhone 15 Pro FineWoven Case with MagSafe - Taupe"&amp;gt;
        &amp;lt;/span&amp;gt;
        &amp;lt;span role="img" aria-label="iPhone FineWoven Wallet with MagSafe - Black"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274990706-ecafd3a0-4a95-4c50-a6f5-69386c548be2.jpeg" alt="iPhone FineWoven Wallet with MagSafe - Black"&amp;gt;
        &amp;lt;/span&amp;gt;
        &amp;lt;span role="img" aria-label="iPhone 15 FineWoven Case with MagSafe - Pacific Blue"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/274990700-6d29a925-9e2a-487f-96c9-7decc3f4fb37.jpeg" alt="iPhone 15 FineWoven Case with MagSafe - Pacific Blue"&amp;gt;
        &amp;lt;/span&amp;gt;
    &amp;lt;/section&amp;gt;
&amp;lt;/section&amp;gt;

    &amp;lt;button type="button" id="forward" class="btn" role="button" aria-label="forward"&amp;gt;
    &amp;lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="30" height="30" class="main-grid-item-icon" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"&amp;gt;
    &amp;lt;polyline points="9 18 15 12 9 6" /&amp;gt;
    &amp;lt;/svg&amp;gt;
&amp;lt;/button&amp;gt;
&amp;lt;/main&amp;gt;

&amp;lt;!-- Buttons --&amp;gt;
&amp;lt;div class="picker-wrapper"&amp;gt;
    &amp;lt;a href="#view1" class="picker-control active" role="link" aria-label="slide picker control"&amp;gt;&amp;lt;/a&amp;gt;
    &amp;lt;a href="#view2" class="picker-control" role="link" aria-label="slide picker control"&amp;gt;&amp;lt;/a&amp;gt;
    &amp;lt;a href="#view3" class="picker-control" role="link" aria-label="slide picker control"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;From the code above, the entire code is wrapped inside a single &lt;em&gt;div&lt;/em&gt; tag of &lt;em&gt;group&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The carousel is split between elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Button:&lt;/strong&gt; The &lt;em&gt;&amp;lt; buttons &amp;gt;&lt;/em&gt; element is placed inside the carousel &lt;em&gt;&amp;lt; main &amp;gt;&lt;/em&gt; element. This makes it easy to be positioned side by side with the carousel element&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Section:&lt;/strong&gt; The &lt;em&gt;&amp;lt; section &amp;gt;&lt;/em&gt; element is a wrapper for each “view” of the carousel items. This makes it easy to style and position each view one at a time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&amp;lt; a &amp;gt;:&lt;/strong&gt; The &lt;em&gt;&amp;lt; a &amp;gt;&lt;/em&gt; element, which is implemented as *picker-control *, is placed at the bottom of the carousel for easy navigation of each carousel view within its container.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the changes to make the carousel more accessible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Button:&lt;/strong&gt; The &lt;em&gt;&amp;lt; buttons &amp;gt;&lt;/em&gt; elements take a &lt;em&gt;role&lt;/em&gt; and &lt;em&gt;aria-label&lt;/em&gt; attributes. This is useful in cases where the content of the button element is an SVG icon and not an actual text. Providing a role=”button” of aria-label=”backward” makes the buttons more accessible for screen readers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Labeling:&lt;/strong&gt; The &lt;em&gt;&amp;lt; main &amp;gt;&lt;/em&gt; element takes a &lt;em&gt;role=”main”&lt;/em&gt; and &lt;em&gt;aria-label=”carousel”&lt;/em&gt;. The &lt;em&gt;role=”main”&lt;/em&gt; indicates where the main content is, while the &lt;em&gt;aria-label=”carousel”&lt;/em&gt; indicates that the main element is a carousel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Span:&lt;/strong&gt; The &lt;em&gt;&amp;lt; span &amp;gt;&lt;/em&gt; element wraps around each image slide and takes a &lt;em&gt;role, aria-label&lt;/em&gt;, and &lt;em&gt;aria-describedby&lt;/em&gt; (view 2 of the section element). The &lt;em&gt;role *indicates the role of the span as an image. The *aria-label&lt;/em&gt; provides what type of image is included in the span while the &lt;em&gt;aria-describedby&lt;/em&gt; describes what type of image is included in the span.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&amp;lt; a &amp;gt;:&lt;/strong&gt; The &lt;em&gt;&amp;lt; a &amp;gt;&lt;/em&gt; element takes the &lt;em&gt;role *of link, and *aria-label&lt;/em&gt; is set to slide picker control.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;role, aria-label,&lt;/em&gt; and &lt;em&gt;aria-describedby&lt;/em&gt; attributes enable screen readers to read the value of these attributes as audible speech for visually impaired users.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Experience real-time &lt;a href="https://www.lambdatest.com/android-device-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android device testing online&lt;/a&gt; with our platform. Ensure compatibility and performance on real devices instantly. Start testing now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   *, *::before, *::after {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    :root {
        --bg-color: rgb(229 231 235);
        --font: calibri;
        --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    }

    body {
        background-color: var(--bg-color);
        width: 100vw;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .carousel {
        width: 100%; 
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }

.carousel-sub {
   width: 70%;
   display: flex;
   overflow-x: scroll;
   scroll-behavior: smooth;
 }

 .img-wrapper {
    transition: all 0.5s ease;
 }

 .carousel .img-wrapper {
     display: flex;
     gap: 20px;
     padding: 10px;
     flex: 0 0 100%;
 }

    .carousel .img-wrapper img {
        width: 100%;
        height: 100%;
        aspect-ratio: 1 /1;
        filter: grayscale(100%);
        transition:transform 0.5s;
        border-radius: 10px;
        box-shadow: var(--shadow);
    }

    .carousel-sub::-webkit-scrollbar {
        display: none;
    }

    .btn {
        display: flex;
        justify-content: center;
        align-items: center;
        border:none;
        width: 50px;
        height: 50px;
        background-color: rgba(0,0,0,.23);
        border-radius: 100%;
        cursor: pointer;
        transition: background 0.5s ease;
    }

    .btn:hover {
        background-color: rgba(0,0,0,.5);
    }

    svg{
        display: block;
    }

    .btn svg {
        stroke: #fff;
    }

    .carousel .img-wrapper img:hover {
        filter: grayscale(0);
        cursor: pointer;
        transform: scale(1.1);
    }

    /* picker-wrapper */
    .picker-wrapper {
        display: flex;
        justify-content: center;
        gap: 1em;
    }

    /* Slide Picker Control */
    .picker-control {
        display: inline-block;
        width: 20px;
        height: 20px;
        background-color: rgba(0,0,0,.23);
        border-radius: 100%;
        transition: all 0.5s ease;
    }

    .picker-control:hover {
        background-color: rgba(0,0,0,.5);
    }

    .active {
        background-color: rgba(0, 0, 0, 0.7);
    }

    .disabled {
        transform: scale(0);
        transition: transform 0.5s ease;
    } 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const carousel = document.querySelector(".carousel-sub"),
            backwardBtn = document.querySelector("#backward"),
            forwardBtn = document.querySelector("#forward");

        const carouselViews = document.querySelectorAll('.img-wrapper')
        const pickerControls = document.querySelectorAll('.picker-control');

        backwardBtn.addEventListener("click", function(e){
            const size = document.querySelector('.carousel-sub').clientWidth;
            carousel.scrollLeft -= `${size}`;

            let i = 0;
            let arr = [...pickerControls];
            let lastIndex = arr.length -1;

            if(carousel.scrollLeft === 0) {
                backwardBtn.classList.add('disabled');
                forwardBtn.classList.remove('disabled')

                arr[i].classList.add('active')
                arr[1].classList.remove('active')
            } 

            else if(carousel.scrollLeft &amp;gt;= 0){
                arr[1].classList.add('active')
                arr[lastIndex].classList.remove('active')

                forwardBtn.classList.remove('disabled')
                backwardBtn.classList.remove('disabled')
            }
        })

        // The forward button for navigating backward
        forwardBtn.addEventListener("click", function(e){
            const size = document.querySelector('.carousel-sub').clientWidth;
            carousel.scrollLeft += `${size}`;

            let i = 0;
            let arr = [...pickerControls];
            let lastIndex = arr.length -1; 

            if(carousel.scrollLeft === 0){
                arr[i].classList.remove('active')
                arr[1].classList.add('active')
                backwardBtn.classList.remove('disabled')

            }

            else if(carousel.scrollLeft &amp;gt;= 0){
                arr[1].classList.remove('active')
                arr[lastIndex].classList.add('active')
                forwardBtn.classList.add('disabled')
            }
        })

        // Carousel Element
        carousel.addEventListener("wheel", function(){
            e.preventDefault();
            carousel.scrollLeft += e.deltaY;
            carousel.style.scrollBehavior = "auto";
        })

        // add active class to picker control

        function eventHandler(index) {
            carouselViews.forEach((view, i)=&amp;gt;{
                pickerControls[i].classList.remove('active')
            })
            pickerControls[index].classList.add('active')
        }

        carouselViews.forEach((view, i)=&amp;gt;{
            pickerControls[i].addEventListener('click', ()=&amp;gt;{
                eventHandler(i)
            })
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/jOXoyGJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
From the code example above, the code snippet performs the following functions;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;carousel&lt;/em&gt; variable is attached to an &lt;em&gt;addEventListener&lt;/em&gt; method that listens for the mouse scroll &lt;em&gt;wheel&lt;/em&gt;. This enables the carousel to scroll when a user scrolls the mouse wheel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;forwardBtn&lt;/em&gt; variable is attached to an &lt;em&gt;addEventListener&lt;/em&gt; method that listens for a &lt;em&gt;click&lt;/em&gt; and takes a callback function with a &lt;em&gt;preventDefault()&lt;/em&gt; method and &lt;em&gt;scrollLeft&lt;/em&gt; property that scrolls the carousel to &lt;em&gt;900px&lt;/em&gt; width when the user clicks the button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;backwardBtn&lt;/em&gt; variable behaves the same way as the &lt;em&gt;forwardBtn&lt;/em&gt; variable, but the &lt;em&gt;scrollLeft&lt;/em&gt; property is set to minus &lt;em&gt;900px&lt;/em&gt;. This moves the carousel slides backward.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;eventHandler&lt;/em&gt; methods remove and add active classes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;carouselViews&lt;/em&gt; is attached to a &lt;em&gt;forEach&lt;/em&gt; method that loops through each element (view) of the &lt;em&gt;carouselViews. Then&lt;/em&gt; each element of the &lt;em&gt;pickerControls&lt;/em&gt; takes an &lt;em&gt;addEventListener&lt;/em&gt; of &lt;em&gt;click&lt;/em&gt; that returns a callback function of &lt;em&gt;eventHandler&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This enables the slider to add an active class to the &lt;em&gt;pickerControl&lt;/em&gt; element to indicate the active element based on the user’s click.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on real iOS and Android devices hosted on the cloud. LambdaTest is a convenient &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cloud android device&lt;/a&gt;, cost-effective and centralised solution .&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Banner Carousels
&lt;/h2&gt;

&lt;p&gt;Banner carousels are types of carousels found primarily on e-commerce platforms. It helps businesses showcase their product in the form of ads.&lt;br&gt;
Unlike other carousels, banner carousels do not require users to navigate through them as they are set to rotate on page load.&lt;/p&gt;

&lt;p&gt;The banner carousel sits typically on top of the page and rotates continuously, one slide at a time. For example, a simple banner carousel from eBay sits on top of the site and displays different types of ads in a slideshow manner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AwWRuTP23vUl6Ds2e.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AwWRuTP23vUl6Ds2e.gif" width="760" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we can see how products are categorized and displayed as ads.&lt;/p&gt;

&lt;p&gt;Now, let’s see how to implement a banner carousel. The below example shows how this is done.&lt;/p&gt;

&lt;p&gt;From the code sample above, we have three image carousels, each occupying the browser viewport.&lt;/p&gt;

&lt;p&gt;Beside these carousel image slides are the &lt;em&gt;Previous Slide Control&lt;/em&gt; and &lt;em&gt;Next Slide Control&lt;/em&gt; buttons for navigating the image slides back and forth.&lt;/p&gt;

&lt;p&gt;Below the image slide are the &lt;em&gt;Slide Picker Controls&lt;/em&gt; for navigating to a specific part of the page. Each picker control is set to a &lt;em&gt;background-color&lt;/em&gt; of &lt;em&gt;gold&lt;/em&gt; for determining which slide is currently active.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Carousel banner &amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;article&amp;gt;
            &amp;lt;!-- Image Slides --&amp;gt;
            &amp;lt;aside role="banner" aria-label="carousel"&amp;gt;
                &amp;lt;div class="image-slides" id="groupImages"&amp;gt;
                    &amp;lt;div id="imageOne" class="image I-one" role="img" aria-describedby="A14 Bionic rockets past other smartphone chip iPhone 12 pro"&amp;gt;
               &amp;lt;img src="https://user-images.githubusercontent.com/78242022/273443252-b034e050-3d70-48ef-9f0f-2d77ef9b2604.jpg" alt=""&amp;gt;
                    &amp;lt;/div&amp;gt;

                    &amp;lt;div id="imageTwo" class="image I-two" role="img" aria-describedby="Calling People Easier then ever. Microsoft smartwatch"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/273443248-130249b5-87b7-423d-9281-48d810bcd30d.jpg" alt=""&amp;gt;
                    &amp;lt;/div&amp;gt;

                    &amp;lt;div id="imageThree" class="image I-three" role="img" aria-describedby="Re-Imagine Optical Excellence with canon DSLR camera"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/273443251-9c210d6f-35ba-4861-885e-9b2e684ab339.jpg" alt=""&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;

             &amp;lt;!-- Slider control buttons --&amp;gt;
            &amp;lt;aside&amp;gt;
                &amp;lt;div class="slider-controls"&amp;gt;
                    &amp;lt;button id="rightBtn" class="right-Btn icon-btn"&amp;gt;&amp;lt;/button&amp;gt;
                    &amp;lt;button id="leftBtn" class="left-Btn icon-btn"&amp;gt;&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;

            &amp;lt;!-- Slide Picker Controls --&amp;gt;
            &amp;lt;aside&amp;gt;
                &amp;lt;div class="picker-controls"&amp;gt;
                    &amp;lt;a href="#imageOne" class="picker active"&amp;gt;&amp;lt;/a&amp;gt;
                    &amp;lt;a href="#imageTwo" class="picker"&amp;gt;&amp;lt;/a&amp;gt;
                    &amp;lt;a href="#imageThree" class="picker"&amp;gt;&amp;lt;/a&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/aside&amp;gt;
        &amp;lt;/article&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;script src="main.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The code above includes semantic HTML elements, Roles, and ARIA attributes to provide structure and information for assistive technologies.&lt;/p&gt;

&lt;p&gt;Using &lt;em&gt;aria-label&lt;/em&gt;, &lt;em&gt;aria-describedby&lt;/em&gt;, and &lt;em&gt;alt&lt;/em&gt; attributes helps provide meaningful information about the carousel to users who rely on screen readers or other assistive technologies.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;&amp;lt; aside &amp;gt;: **The *aside&lt;/em&gt; elements serve as a wrapper for the sliders in the carousel. It takes a &lt;em&gt;role=”banner”&lt;/em&gt; to indicate that the first &lt;em&gt;&amp;lt; aside &amp;gt;&lt;/em&gt; element serves as a banner. The &lt;em&gt;aria-label=”carousel”&lt;/em&gt; provides a label for assistive technologies to identify this banner as a carousel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Image Slides: **Each *&amp;lt; div &amp;gt;&lt;/em&gt; with class &lt;em&gt;image&lt;/em&gt; represents a slide in the carousel, and &lt;em&gt;role=”img”&lt;/em&gt; indicates that these are images. The &lt;em&gt;aria-describedby&lt;/em&gt; provides a description for each image that screen readers can read.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Slider Control Buttons: **The buttons have *role=”button&lt;/em&gt;” to indicate that they are interactive elements and can be read by screen readers. These buttons include the forward and backward buttons for navigation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slide Picker Controls&lt;/strong&gt;: They have a class &lt;em&gt;picker,&lt;/em&gt; which suggests they are used to select specific slides. The first link has class &lt;em&gt;active&lt;/em&gt;, indicating it’s the currently selected slide.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*, *::after, *::before {
    padding: 0;
    margin: 0;
    box-sizing: 0;
}

*,*::before, *::after {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

main {
    display: grid;
    align-items: center;
    width: 100vw;
    height: 100vh;
}

.image-slides {
    width: 100vw;
    height: 50%;
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
}

.image {
    flex: 0 0 100vw;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    overflow: hidden;
}

.image &amp;gt; img{
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slider-controls {
    display: flex;
}

.right-Btn, .left-Btn {
    background: none;
    border: none;
    width: 3em;
    height: 6em;
    padding: 2em 10px;
    display: block;
    cursor: pointer;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 3em;
    position: absolute;
    bottom: 45%;
    z-index: 6;
}


.right-Btn {
    background-image:url("data:image/svg+xml,%3csvg xmlns=\'http://www.w3.org/2000/svg\' fill=\'%23fff\' viewBox=\'0 0 8 8\'%3e%3cpath d=\'M2.75 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z\'/%3e%3c/svg%3e");
    right: 3em;
}

.left-Btn {
    background-image:url("data:image/svg+xml,%3csvg xmlns=\'http://www.w3.org/2000/svg\' fill=\'%23fff\' viewBox=\'0 0 8 8\'%3e%3cpath d=\'M5.25 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z\'/%3e%3c/svg%3e");
    left: 3em;
}

.right-Btn::after, .left-Btn::before {
    content: "";
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background-color: rgba(255, 166, 0, 0.397);
    position: absolute;
    inset: 0;
    transition: background 0.5s linear;
    z-index: 1;
}

.image-slides::-webkit-scrollbar {
        display: none;
    }

.right-Btn:hover::after, .left-Btn:hover::before {
    background-color: rgba(255, 166, 0, 0.568);
}

.picker-controls {
    display: flex;
    justify-content: center;
    gap: 1em;
    transform: translateY(-30px);
}

a {
    text-decoration: none;
    width: 2.5em;
    height: 0.5em;
    background-color: white;
    opacity: 0.5;
    transition: opacity 0.5s ease;
}

a:hover {
    opacity: 1;
}

.active {
    background-color: gold;
    opacity: 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const rightBtn = document.querySelector("#rightBtn");
const leftBtn = document.querySelector("#leftBtn");
const imageSlides = document.querySelector(".image-slides");
const images = document.querySelectorAll(".image");

const imageSize = document.querySelector(".image").clientWidth;

const pickerControls = document.querySelectorAll(".picker");

// Control Picker Element
const pickerOne = document.querySelector('[href="#imageOne"]');
const pickerTwo = document.querySelector('[href="#imageTwo"]');
const pickerThree = document.querySelector('[href="#imageThree"]');

rightBtn.addEventListener("click", moveForward);
leftBtn.addEventListener("click", moveBackward);

function moveForward(e) {
  imageSlides.scrollLeft += `${imageSize}`;  

  if (imageSlides === 0) {
    pickerTwo.classList.add("active");
    pickerOne.classList.remove("active");
  } 

  else if (imageSlides.scrollLeft === 1366) {
    pickerThree.classList.add("active");
    pickerTwo.classList.remove("active");
  } 

  else if (imageSlides.scrollLeft === 2732) {
    imageSlides.scrollLeft = 0;
    pickerOne.classList.add("active");
    pickerThree.classList.remove("active");
    console.log(imageSlides.scrollLeft);
  }
}

function moveBackward() {
  imageSlides.scrollLeft -= imageSize;
}

setInterval(moveForward, 1000)

// activating Active Links on Control Picker
function returnActiveLink(index) {
  images.forEach((image, i) =&amp;gt; {
    pickerControls[i].classList.remove("active");
  });
  pickerControls[index].classList.add("active");
}

images.forEach((image, i) =&amp;gt; {
  pickerControls[i].addEventListener("click", () =&amp;gt; {
    returnActiveLink(i);
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/ExGBKqz?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on real iOS and Android devices hosted on the cloud. LambdaTest is a convenient, cost-effective and centralised solution for running realtime and Automated test on &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cloud device for testing&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From the browser output above, the carousel is set to 100 viewport width on the desktop and positioned to the middle of the page. Shown below is the output on LT Browser on different screen sizes. This will help to check how banner carousels perform in terms of responsiveness on different device viewports like desktops, mobiles, and tablets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LT Browser&lt;/a&gt; is a free, Chromium-based browser for web developers to help them build, test, and debug their websites and web applications across various pre-installed device viewports. It’s a desktop application that offers a variety of features to make &lt;a href="https://www.lambdatest.com/learning-hub/responsive-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;responsive testing&lt;/a&gt; easier and more efficient.&lt;/p&gt;

&lt;p&gt;Here are some of the key features of LT Browser:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;50+ pre-installed device viewports&lt;/strong&gt;: You can test your website on a variety of popular devices, including smartphones, tablets, laptops, and desktops, without having to manually configure each one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Live interactive testing&lt;/strong&gt;: You can interact with your website in real-time as you test it on different devices, making it easy to identify and fix any issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network throttling&lt;/strong&gt;: You can simulate different network conditions, such as slow 4G or offline, to see how your website performs under different circumstances.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Screenshot and bug reporting&lt;/strong&gt;: You can easily take screenshots of your website on different devices and report bugs directly to your project management tool.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integrations with popular tools&lt;/strong&gt;: LT Browser integrates with various tools, such as Jira, Asana, Trello, GitHub, ClickUp, Slack, and Microsoft Teams.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Desktop Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mobile Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A7vlMGqF0vfFcfsOC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A7vlMGqF0vfFcfsOC.png" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tablet Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AXctXDRoMLg3_KBEP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AXctXDRoMLg3_KBEP.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on real iOS and Android devices hosted the &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile device cloud&lt;/a&gt;. LambdaTest is a convenient, cost-effective and centralised solution for running realtime and Automated test on real device cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Testimonial Carousels
&lt;/h2&gt;

&lt;p&gt;Adding testimonials to your web page is a great way to instill confidence in a user about your product. This can quickly be done by creating a simple HTML mockup and CSS styling that displays the testimonials on the page.&lt;/p&gt;

&lt;p&gt;However, there are cases where there are many testimonials to display. In this case, the testimonials can be implemented as a carousel that displays several testimonials from a single view. For example, Hashnode uses sample slide animation testimonials to display to the users on the home page.&lt;/p&gt;

&lt;p&gt;Similar examples can also be seen on CodeSandbox.&lt;br&gt;
&lt;a href="https://giphy.com/channel/LambdaTesting?utm_source=iframe&amp;amp;utm_medium=embed&amp;amp;utm_campaign=Embeds&amp;amp;utm_term=https%3A%2F%2Fwww.lambdatest.com%2Fblog%2Faccessible-carousels%2F" rel="noopener noreferrer"&gt;&lt;strong&gt;Lambdatesting GIFs on GIPHY - Be Animated&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s see how to implement the above cases on a web page.&lt;/p&gt;

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

&lt;p&gt;The example above shows how multiple elements can be implemented as a carousel that animates horizontally across the page.&lt;/p&gt;

&lt;p&gt;The element &lt;em&gt;animation-iteration-count&lt;/em&gt; is set to &lt;em&gt;infinite&lt;/em&gt; to enable the animation sequence to keep repeating itself. In contrast, the &lt;em&gt;animation-play-state&lt;/em&gt; is set to run to keep the animation going.&lt;/p&gt;

&lt;p&gt;However, each animation is set to pause on hover to stop it from running. This is very useful as it lets users pause the animation and read the testimonials.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Carousel Hover&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;main class="main"&amp;gt;
        &amp;lt;aside class="card-group g1" role="main" aria-label="carousel"&amp;gt;
            &amp;lt;!-- Card One --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;
                    Awesome job you did there &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; with the LT Browser. It's doing a fantastic job at responsive testing 🔥 see more &amp;gt;
                &amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654602-6b6c4303-587d-48ae-957a-3b88496f1fcc.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Mbaziira Ronald&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@MbaziiraRonn&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Two --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Amazing Test software. I am very satisfied, I think it is excellent software and as the years go by it continues to offer the best service I have ever tried....see more &amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654585-d0774fd3-5d90-42f0-bc53-7141f7735825.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Elias M.&amp;lt;/h4&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Three --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Anyone who needs to test their code on different platforms try &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; Great service from this company!&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013776-40ac50f1-31f8-4250-acb2-05f16d683baa.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Stephan Smuts&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;spsmuts&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Four --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;See how &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; is #Futureready to enable blazing-fast test orchestration seamlessly integrated with organizations' existing CI/CD platforms, using #Microsoft Azure.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654608-d291d9df-439c-4a79-83b1-2f2d71cd25b5.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Microsoft India&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@MicrosoftIndia&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Five --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Amazing Experience. That reduces a large amount of cost as well as manhours which can be used for other better things. In our team we have integrated lambdatest with our automation CI/CD pipeline, this shows how we trust &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt;...see more &amp;gt;.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654585-d0774fd3-5d90-42f0-bc53-7141f7735825.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Padma kumar M.&amp;lt;/h4&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

             &amp;lt;!-- Card Six --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;&amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; Efficient and User-Friendly Cross-Browser Testing with LambdaTest...see more &amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013732-785b0223-9774-4918-964f-ce75f11138f2.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Ravi Kanth G.&amp;lt;/h4&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;
        &amp;lt;/aside&amp;gt;

        &amp;lt;!-- Group 2 --&amp;gt;
        &amp;lt;aside class="card-group g2"&amp;gt;
            &amp;lt;!-- Card One --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Thank you &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; for providing free open source license to run the web and mobile tests of our open source projects for free on Lambdatest platform.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013783-757ea2d1-e396-4d56-ade8-8b641f78ce71.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Mohammad Faisal Khatri&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@faisalkhatri&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Two --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Super top notch customer support from &amp;lt;em&amp;gt; @lambdatesting&amp;lt;/em&amp;gt; - just throwing it out there if you're looking for a decent browser testing platform, they get my full double thumbs up. Thumbs upThumbs up :-) &amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013790-4d674d96-a311-47c3-9b7c-03feaa36c948.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Ben Pritchard&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@yesiamben&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

             &amp;lt;!-- Card Three --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;&amp;lt;em&amp;gt; @lambdatesting&amp;lt;/em&amp;gt; is fantastic. Cross browser and device testingtesting frustration is minimized. You can't get rid of clients that need ie11 nor can you own every device but lambda test bridge that gap.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013776-40ac50f1-31f8-4250-acb2-05f16d683baa.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Mat Gargano&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt; @matgargano&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Four --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;second-day using &amp;lt;em&amp;gt; @lambdatesting&amp;lt;/em&amp;gt; and it's already proven itself a lot faster than Cross Browser Testing and BrowserStack, at half the price! bargain&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013762-54201d6a-0923-4969-948c-790dec804253.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Matthew Bryson&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt; @mbrysonuk&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Five --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Really superb customer service from Arpit &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; tricky Automation problem using Selenium in Python and they talked me through it and got me up-and-running. Awesome.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013745-c09f21ff-cb29-49df-9110-d5e90810b5b9.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Michael (Mike) Horne&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@recantha&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Six --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;&amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; can I just say, your support team are first class. I had the pleasure of talking with Prateek Singh. He went the extra mile and nothing was too much trouble. Clearly your support is also very technically adept, something which I really value. Thank you!&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013732-785b0223-9774-4918-964f-ce75f11138f2.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Timothy Wintle&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt; @timwintle1979&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;
        &amp;lt;/aside&amp;gt;

        &amp;lt;!-- Group 3 --&amp;gt;
         &amp;lt;aside class="card-group g3"&amp;gt;
            &amp;lt;!-- Card One --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Also I recommend using &amp;lt;em&amp;gt; @lambdatesting&amp;lt;/em&amp;gt; for testing out in all the devices. I am personally using it for my MERN project testing as well.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654599-4bc5d6e9-da64-47fd-83ae-4cbf109fed16.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Masroor Ejaz&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@MasroorEjaz&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Two --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Checkout LambdaTest -&amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; Perform manual or automated cross browser testing on 3000+ browsers online. Deploy and scale faster with the most powerful cross browser test... see more &amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654591-2bc192b0-9c97-4fbf-a55c-e60791acc4c6.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Dev Tools&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@finddevtools&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Three --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Browser for Designers &amp;amp; UI Developers Need to Test your App on Multiple Devices ? 🤔 Meet LT Browser by &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; See more &amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654594-c037ce6e-6fdc-42f9-a4f6-07419089b689.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Satyam Anand&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@IncodeSatx&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Four --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Quick way to test IE and MAC OS specific issues. Ability to spawn an instance within seconds and start working instantly....see more &amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654625-985aaf83-2f72-4a57-9eb3-10fbe52d8413.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Syed Haroon P.&amp;lt;/h4&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Five --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;Really superb customer service from Arpit &amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; &amp;lt;/em&amp;gt; tricky Automation problem using Selenium in Python and they talked me through it and got me up-and-running. Awesome.&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/266013745-c09f21ff-cb29-49df-9110-d5e90810b5b9.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                        &amp;lt;h4 role="heading" aria-label="4"&amp;gt;Michael (Mike) Horne&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@recantha&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;!-- Card Six --&amp;gt;
            &amp;lt;section class="card c1"&amp;gt;
                &amp;lt;p class="text" role="paragraph" aria-label="testimonial"&amp;gt;&amp;lt;em&amp;gt;@lambdatesting&amp;lt;/em&amp;gt; #TestMuConf 2023 has been interesting so far with lots of quality sessions with industry experts sharing from their wealth of knowledge and experience... Thank you LambdaTest for hosting this conference... see more &amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="s1"&amp;gt;
                        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/272654627-1536d3df-c0f2-414c-b631-0bd1159db223.png" alt=""&amp;gt;
                    &amp;lt;/span&amp;gt;
                    &amp;lt;span class="s2"&amp;gt;
                      &amp;lt;h4 role="heading" aria-label="4"&amp;gt;WALIU ANUOLUWAPO SANNI&amp;lt;/h4&amp;gt;
                        &amp;lt;p class="at"&amp;gt;@WALIUANUOLUWAPOSANNI&amp;lt;/p&amp;gt;
                    &amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;
        &amp;lt;/aside&amp;gt;&amp;lt;!-- End of Group 3 --&amp;gt;
    &amp;lt;/main&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;real Android devices online&lt;/a&gt;. LambdaTest is a convenient, cost-effective and centralised solution for running realtime and Automated test on real device cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From the code sample above, the element is broken down into six cards, and each six cards is divided into three groups.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Cards: **Each card contains a paragraph with a *role=’’paragraph”&lt;/em&gt; indicating that it should be read as a paragraph by screen readers, and &lt;em&gt;aria-label=”testimonials”&lt;/em&gt; indicating that this paragraph should be read as a testimonial.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Card numbers and group: **The cards are numbered into six and grouped into three, making it possible for users to interact with each group individually rather than with each card.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*, *::after, *::before {
    padding: 0;
    margin: 0;
    box-sizing: 0;
}

body{
    background-color: #EEF5FF;
    overflow-x: hidden;
}

.main {
    width: 100vw;
    height: 100vh;
    display: grid;
    place-items: center;
}

.card-group{
   display: flex;
   gap: 1em;
}

.card {
    width: 445px;
    height: fit-content;
    padding: 15px 30px;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px 0 rgba(0,0,0,.06);
    -webkit-user-select: none;

    user-select: none;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid #aaaaaa;

    transform: translate(-1800px);

        animation-name: moveforward;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
        animation-duration: 10s;
        animation-play-state: running;
}

.g1 .card, .g3 .card {
    transform: translate(1800px);
    animation-duration: 20s;
    animation-name: movebackword;
}

.g1:hover .card {
    animation-play-state: paused;
}

.g2:hover .card {
    animation-play-state: paused;
}

.g3:hover .card {
    animation-play-state: paused;
}


.card .text {
    font: 14px Arial;
    color: #4a4a4a;
    line-height: 21px;
}

.card h4 {
    font: 16px Arial;
    font-weight: 600;
    color: black;
}

.card .at {
    font: 16px Arial;
    font-weight: 400;
    color: #007bff;
    margin-top: 4px;
}

.card img {
    width: 50px;
    height: 50px;
    border-radius: 50px;
}

.card div {
    display: flex;
    margin: 10px 0 0;
    gap: 10px;
}
em {
    font-style: normal;
    color: #007bff;
}

@keyframes moveforward {
    0%{
        transform: translateX(0);
    }
    100%{
        transform: translateX(-1800);
    }
}

@keyframes movebackword {
    0%{
        transform: translateX(0);
    }
    100%{
        transform: translateX(1800);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the next section of this article, we will look at how to ensure accessible carousels by performing accessibility testing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.lambdatest.com/android-device-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;**Test on android device online&lt;/a&gt; with our platform. Ensure compatibility and performance on real devices instantly. Start testing now!**&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to Test the Accessibility of Carousels?
&lt;/h2&gt;

&lt;p&gt;Ensuring accessible carousels requires screen readers to test different page sections. This is very useful when a carousel element with WAI-ARIA is implemented on each component, such as buttons, slides, slider picker controls, containers, etc.&lt;/p&gt;

&lt;p&gt;To test how screen readers read the specified WAI-ARIA Roles, States, and Properties defined on the carousel elements, you can leverage cloud-based accessibility testing platforms to ensure accessible carousels on different combinations of browsers and operating systems.&lt;/p&gt;

&lt;p&gt;AI-powered test orchestration and execution platforms like LambdaTest offer &lt;a href="https://www.lambdatest.com/learning-hub/accessibility-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;accessibility testing&lt;/a&gt; of websites and web apps on over 3000+ real browsers and OSes.&lt;/p&gt;

&lt;p&gt;We use the LambdaTest screen reader feature on Real Time Browser Testing to run accessibility checks. This will read the WAI-ARIA Roles, States, and Properties specified on the element as audible text, giving the same user experience as a visually impaired user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Afv1OL2GGCEbNa20f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Afv1OL2GGCEbNa20f.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check out the tutorial below that explains how to test websites in Real Time on the LambdaTest platform.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WYbyLfLM2-E"&gt;
&lt;/iframe&gt;
&lt;br&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=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; to catch up with the latest videos on &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;To make sure the carousels are accessible to all users, there are a few best practices that must be followed. Let’s look at some of the best practices to create accessible carousels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;**Test on real mobile devices&lt;/a&gt; for your native app and website on real iOS and Android devices hosted in the cloud. LambdaTest provides a convenient, cost-effective, and centralized solution for conducting real-time and automated tests on a real device cloud.**&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Best Practices for Accessible Carousels
&lt;/h2&gt;

&lt;p&gt;To ensure carousels are well implemented, we can consider the following best practices.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;**Easy navigation: **Ensure that the carousel slides are easily navigated by implementing navigation controls and control pickers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Image quality and bold text: **Quality images with bold text should be implemented to encourage users to click through the slides.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Reduce the number of slides: **Avoid multiple carousel slides to maximize engagement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Design consistency: **Ensure all elements, slides, and navigation controls, maintain consistent style in appearance such as height, width, colors, fonts, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Avoid autoplay sounds: **Ensure sounds are disabled to prevent unpleasant sounds. Users should be given the option to enable sounds for a better experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Semantics: **To ensure that carousels are compatible across multiple browsers, developers should write well-semantic mockups and use the appropriate WAI-ARIA Roles, States, and Properties when implementing accessible features on mockups.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Performance tracking and analytics: **Track the performance of the carousel to understand how users interact with each carousel component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Fallback options via vendor prefixes: **Vendor prefixes such as *-webkit-&lt;/em&gt;, &lt;em&gt;-moz-&lt;/em&gt;, and &lt;em&gt;-ms-&lt;/em&gt; just to mention a few, should be used on properties that require vendor prefixes to work well. This will help create a good fallback for legacy browser versions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adequate testing should be implemented to ensure the carousel components, such as &lt;em&gt;previous slide control, next slide control, slide picker controls,&lt;/em&gt; and &lt;em&gt;pause/play&lt;/em&gt; control, are rendered correctly on different browsers for a better user experience.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;android real device testing&lt;/a&gt;. LambdaTest offers a convenient, cost-effective, and centralized solution for running real-time and automated tests on real device cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Carousels help boost users’ engagement and prevent endless scrolling in search of related content or items on the page. However, to create accessible carousels, WAI-ARIA Roles, States, and Properties that enable carousels to be accessible need to be specified within the semantic HTML mockups of the carousel components.&lt;/p&gt;

&lt;p&gt;Accessible carousels enable assistive technology tools such as screen readers, text-to-speech, and refreshable braille display software to read WAI-ARIA, Roles, States, and Properties as audible speech for visually impaired users.&lt;/p&gt;

&lt;p&gt;Ensure you test each WAI-ARIA Roles, States, and Properties specified on the carousel elements using &lt;a href="https://www.lambdatest.com/blog/accessibility-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;accessibility testing tools&lt;/a&gt;. This will enable you to get real user feedback on how the carousel will be used for visually impaired users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the function of the carousel?
&lt;/h3&gt;

&lt;p&gt;Carousels help showcase multiple items in limited space, promote key content, add dynamism, and save space. But remember, accessibility matters: use them wisely and prioritize inclusive design!&lt;/p&gt;

&lt;h3&gt;
  
  
  Why are carousels not accessible?
&lt;/h3&gt;

&lt;p&gt;While carousels seem visually appealing, they create accessibility issues. Autoplay disrupts impaired users, navigation is often clunky for keyboards and screen readers, and vital information hidden in images is inaccessible. Opt for alternative layouts to ensure everyone can easily access your content.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I make an accessible slider?
&lt;/h3&gt;

&lt;p&gt;Make your slider accessible by structuring it clearly with semantic HTML, ensuring keyboard navigation with arrow keys and dedicated shortcuts, offering screen reader compatibility through aria attributes, maintaining good contrast and focus indication, providing text alternatives for non-text content, and avoiding autoplay.&lt;/p&gt;

&lt;p&gt;Bonus points for offering keyboard shortcuts, alternative input methods for touchscreens, and thorough testing with assistive technologies! Remember, inclusivity matters.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Try out real-time Android device testing online with our platform. &lt;a href="https://www.lambdatest.com/android-device-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Test android app on multiple devices online&lt;/a&gt;, ensure compatibility and performance on real devices instantly. Start testing now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can also see the same method replicated on the Motorola website, where each slide showcases the organization’s products as an ad. These types of carousels are banner carousels.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>A Complete Guide To CSS Masking</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Tue, 25 Jul 2023 15:39:41 +0000</pubDate>
      <link>https://forem.com/testmuai/a-complete-guide-to-css-masking-pfd</link>
      <guid>https://forem.com/testmuai/a-complete-guide-to-css-masking-pfd</guid>
      <description>&lt;p&gt;Since the inception of the web, &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=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;web design&lt;/a&gt; has been a huge part of it. Web designers use different approaches to design web pages, but this comes with some limitations, as only some designs can be implemented on the web, especially when working with media files, image assets, or SVG files.&lt;/p&gt;

&lt;p&gt;Things can get complex and, most times, difficult to do. For example, before the introduction of CSS masking, designers used raster graphic editing software like Photoshop to add CSS masking to images before importing them to the web.&lt;/p&gt;

&lt;p&gt;This approach can be a herculean task, especially when working with larger or multiple images.&lt;/p&gt;

&lt;p&gt;One can not apply CSS masking to 50 or more images before importing them for use on the web. Doing so will lead to a slow and tedious development process, not to mention. There are cases of accessibility, &lt;a href="https://www.lambdatest.com/learning-hub/cross-browser-compatibility?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;browser compatibility&lt;/a&gt;, and color contrast, just to mention a few.&lt;/p&gt;

&lt;p&gt;To fix this problem, the CSS masking property has been added to the CSS specification. This enables the smoothness and ease of applying masks to images on the web.&lt;/p&gt;

&lt;p&gt;In this blog, we will explore what is CSS masking and how to apply CSS masking to blend images, videos, text, SVGs (Scalable Vector Graphics). We will also look at CSS masking properties and sub-properties, CSS mask border properties, browser compatibility, and other CSS masking properties and their use cases.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This article will walk you through the best software &lt;a href="https://www.lambdatest.com/blog/best-software-testing-certifications/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing certification&lt;/a&gt; that will help boost your career as a test automation engineer.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is CSS Masking
&lt;/h2&gt;

&lt;p&gt;CSS masking involves partially or fully hiding parts of a visual element, such as images, videos, or SVGs. Applying CSS masking involves using another graphical element, such as images, SVGs, or text, as an alpha or luminance mask.&lt;/p&gt;

&lt;p&gt;When using an alpha mask, the object receiving the mask conforms to the shape of the object that is applying the mask. The shape becomes visible while other parts of the element become partially or fully hidden.&lt;/p&gt;

&lt;p&gt;Let’s look at an example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2AYq7pvPQNQpkV15bX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2AYq7pvPQNQpkV15bX.png" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the illustration above, we have two images, one with a *jpg *and the other with a *png *file extension. The *png *image supports transparency, which is best for CSS masking.&lt;/p&gt;

&lt;p&gt;To make the CSS masking technique work, the &lt;em&gt;mask&lt;/em&gt;.&lt;em&gt;png *is used as a mask to cover the *image.jpg&lt;/em&gt; file revealing only the portion of the mask image shape.&lt;/p&gt;

&lt;p&gt;Look at the below image for a clear vision:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2Anv1nPFLjqjS7AZuG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2Anv1nPFLjqjS7AZuG.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Learn why Python is the top choice for automation testing. This comprehensive tutorial provides a step-by-step guide to &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing using python&lt;/a&gt; to help you streamline your testing process.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Contrary to what you would think, CSS masking doesn’t crop out the image; instead, it hides part of the surrounding area of the object leaving only the mask area. This enables us to style the mask using the mask properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-Life Examples of Websites using CSS Masking
&lt;/h2&gt;

&lt;p&gt;CSS masking has many benefits. It allows web designers and developers to hide parts of an element on the web. This can be either through text, PNG image shapes, or SVG elements. However, masking in CSS is not limited to hiding parts of an element. It can also be used to apply transparency to web elements, making the element blend well with the web page’s background.&lt;/p&gt;

&lt;p&gt;Let’s look at real-world examples of where CSS masking has been used on popular websites.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making Content Text
&lt;/h2&gt;

&lt;p&gt;Here is a simple example of how LambdaTest used CSS masking to hide some parts of the content from the user with an option to reveal upon click (the &lt;strong&gt;&lt;em&gt;Read More&lt;/em&gt;&lt;/strong&gt; button). This limited the amount of content exposed to the user when browsing the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AWsZIuu9xFONXVrAB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AWsZIuu9xFONXVrAB.png" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This technique can be very helpful as it allows users to scroll through multiple options before deciding on the actual top to read.&lt;/p&gt;

&lt;p&gt;However, it can also be used to restrict who gets access to particular content, such as exclusive content for subscribers.&lt;/p&gt;

&lt;p&gt;Here is a perfect example from the Atlantic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmXS9nOoLmyXJ1Xy9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmXS9nOoLmyXJ1Xy9.png" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, some parts of the web page are faded for subscribers only. This gives web authors control over who reads the content they publish on their website.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Get started with this comprehensive &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing using Selenium &lt;/a&gt;tutorial. Learn what Selenium is, its architecture, advantages and more for automated cross browser testing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Linear Gradient Fading
&lt;/h2&gt;

&lt;p&gt;While making content is great and has benefits, Images can also be blended with the page’s background.&lt;/p&gt;

&lt;p&gt;This technique is handy, especially with landing pages. The MasterClass is a perfect example of how making images with linear gradients can improve user experience.&lt;/p&gt;

&lt;p&gt;As you can see from their website, the CTAs buttons and display text have good color contracts from the background image and the web page’s background.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2702%2F0%2A_dN0vKMufXXM9nfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2702%2F0%2A_dN0vKMufXXM9nfs.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CSS is masking an image with a linear gradient that works simply. The black in the alpha channel is used to hide some parts of the image. The size or direction of the mask can be specified in the degree to determine how large the mask should grow to cover the selected image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browser Compatibility
&lt;/h2&gt;

&lt;p&gt;The browser compatibility for CSS masking is not fully supported in all browsers at the time of writing.&lt;/p&gt;

&lt;p&gt;Browsers such as Chrome, Opera, and Edge have partial support and require the use of the &lt;em&gt;-webkit-&lt;/em&gt; prefix for the property to function correctly. However, Safari and Firefox fully support specifying the property without vendor prefixes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AFCXwwPg7jdA5Z-P8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AFCXwwPg7jdA5Z-P8.png" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source- caniuse.com&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Masking Properties
&lt;/h2&gt;

&lt;p&gt;The CSS masking properties are required when you want to add additional styling to a masking effect. For example, we can create a mask with the &lt;em&gt;mask-image&lt;/em&gt; property and reposition it with the &lt;em&gt;mask-position&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2AM5mpqXS_IudnAdvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2AM5mpqXS_IudnAdvm.png" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image illustrates how to use the mask property in CSS masking.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prepare to ace your &lt;a href="https://www.lambdatest.com/learning-hub/nunit-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;NUnit interviews questions&lt;/a&gt; with our thorough set of solutions that will enable you to prove your command of the NUnit testing framework.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  mask-image property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-image&lt;/em&gt; CSS masking property enables objects that support transparency to be used as a mask for another object or element.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-image&lt;/em&gt; CSS masking property uses the &lt;em&gt;url()&lt;/em&gt; CSS function to set the URL of the object to be used as a mask. However, in the absence of an image or SVG file, a gradient mask can be applied to the object&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; /* Keyword value */
mask-image: none;

 /*   Using gradient     */
-webkit-mask-image: linear-gradient(#000, transparent);
mask-image: linear-gradient(#000, transparent);

/*   Using images */
-webkit-mask-image: url('/img/curved-triangle.svg');
mask-image: url('/img/curved-triangle.svg');

/*   Global Values  */
mask-image: initial;
mask-image: inherit;
mask-image: revert;
mask-image: unset;
mask-image: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Applying a gradient to mask-image
&lt;/h3&gt;

&lt;p&gt;Here, we used the mask-image CSS masking property to apply a gradient mask to a specific element on the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section One --&amp;gt;
        &amp;lt;section class="normal-container"&amp;gt;
            &amp;lt;h1&amp;gt;Normal Image&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="normal"&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;h1&amp;gt;Gradient Mask&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="masking"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; body {
            overflow: hidden;
        }

        .main{
            display: grid;
            grid-template-columns: 1fr 1fr;
            grid-template-rows: auto;
            gap: 10px;
        }

        img {
            width: 100%;
        }

        h1 {
            font-size: 3em;
            font-family: calibri;
            text-transform: uppercase;
            margin: 0;
            background-color: aqua;
            text-align: center;
        }

        .normal {
            mask-image: linear-gradient(#000, transparent);
        }

        .masking {
            -webkit-mask-image: linear-gradient(#000, transparent);
            mask-image: linear-gradient(#000, transparent);
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/wvYZWKV?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Navigate your Laravel interview with ease! Our guide covers over 190 &lt;a href="https://www.lambdatest.com/learning-hub/laravel-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Laravel interview questions&lt;/a&gt; to help you land your ideal tech job.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Chrome Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AhiJu3m06e-vz6-Ms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AhiJu3m06e-vz6-Ms.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the Chrome browser preview, the &lt;em&gt;mask-image: linear-gradient(#000, transparent)&lt;/em&gt;&lt;br&gt;
only works on the second image and not the first one; this is because we set only one property on the normal-container element and the &lt;em&gt;-webkit- prefix&lt;/em&gt; is omitted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firefox Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AtAAu54kA1jTQkeeS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AtAAu54kA1jTQkeeS.png" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the Firefox browser preview, the &lt;em&gt;mask-image: linear-gradient(#000, transparent)&lt;/em&gt; works on both images because a browser prefix is unnecessary for the &lt;em&gt;mask-image&lt;/em&gt; to function correctly.&lt;/p&gt;

&lt;p&gt;The above browser output is run on Firefox with LambdaTest Real Time Testing. LambdaTest is a digital experience testing platform that allows you to check your CSS framework-based web projects across desktop and mobile environments. It lets you perform manual and &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated testing&lt;/a&gt; on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm &lt;/a&gt;of 3000+ real browsers, devices, and operating systems combinations.&lt;/p&gt;

&lt;p&gt;To get the best result when working with the mask-composite property, try using Firefox instead of Chrome due to &lt;a href="https://www.lambdatest.com/blog/css-browser-compatibility-issues/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;browser compatibility issues&lt;/a&gt;.&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;Subscribe to &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=video" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and get detailed tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applying gradient direction to mask-image
&lt;/h3&gt;

&lt;p&gt;We’ve seen how to apply gradients; the next thing to do is use the direction to linear gradients in mask-image.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section One --&amp;gt;
        &amp;lt;section class="normal-container"&amp;gt;
            &amp;lt;h1&amp;gt;to top&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="to-top"&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;h1&amp;gt;To right&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="to-right"&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;h1&amp;gt;to bottom&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="to-bottom"&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;h1&amp;gt;to left&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="to-left"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
        gap: 10px;
    }

    img {
        width: 100%;
    }

    h1 {
        font-size: 3em;
        font-family: calibri;
        text-transform: uppercase;
        margin: 0;
        background-color: aqua;
        text-align: center;
    }

    /* Fading the image from the bottom to the top */
    .to-top {
        mask-image: linear-gradient(to top, transparent, #000);
        -webkit-mask-image: linear-gradient(to top, transparent, #000);
    }

    /* Fading the Image from left to right */
    .to-right {
        mask-image: linear-gradient(to right, transparent, #000);
        -webkit-mask-image: linear-gradient(to right, transparent, #000);
    }

    /* Fading the image from top to bottom */
    .to-bottom {
        mask-image: linear-gradient(to bottom, transparent, #000);
        -webkit-mask-image: linear-gradient(to bottom, transparent, #000);
    }

    /* Fading the image from right to left */
    .to-left {
        mask-image: linear-gradient(to left, transparent, #000);
        -webkit-mask-image: linear-gradient(to left, transparent, #000);
    }
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/RweORrq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ace your Unit testing interviews with our comprehensive &lt;a href="https://www.lambdatest.com/learning-hub/unit-testing-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Unit testing interview questions &lt;/a&gt;and solutions for unit testing, covering topics from syntax to advanced techniques.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A_qE6giTjq7cj_OFI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A_qE6giTjq7cj_OFI.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we applied a linear gradient to four different directions on four separate elements on the web page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applying gradient angle in the degree to mask-image
&lt;/h3&gt;

&lt;p&gt;We can also specify the direction of the &lt;em&gt;mask-image&lt;/em&gt; gradient in degrees. This will enable the angle to move in different directions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="main"&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;h1&amp;gt;Side by side masking&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="left-right"&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;h1&amp;gt;Top and Bottom Masking&amp;lt;/h1&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="top-bottom"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
        gap: 10px;
    }

    img {
        width: 100%;
    }

    h1 {
        font-size: 3em;
        font-family: calibri;
        text-transform: uppercase;
        margin: 0;
        background-color: aqua;
        text-align: center;
    }

    .left-right{
        -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%, #000 70%, transparent 100%);
        mask-image: linear-gradient(90deg, transparent, #000 40%, #000 70%, transparent 100%);
    }

 .top-bottom{
        -webkit-mask-image: linear-gradient(180deg, transparent, #000 20%, #000 60%, transparent 100%);
        mask-image: linear-gradient(180deg, transparent, #000 20%, #000 60%, transparent 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;iframe height="600" src="https://codepen.io/ocxigin/embed/XWxQKKg?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This tutorial focuses on &lt;a href="https://www.lambdatest.com/learning-hub/mobile-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;mobile ui testing,&lt;/a&gt; its significance, benefits, strategies, challenges, and best practices.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A-29DV8lHImNUiC5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A-29DV8lHImNUiC5m.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we specify the &lt;em&gt;mask-image&lt;/em&gt; gradient to an angle of &lt;em&gt;90 deg and 180 deg&lt;/em&gt;, respectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applying image to mask-image
&lt;/h3&gt;

&lt;p&gt;Applying images to &lt;em&gt;mask-image&lt;/em&gt; is very similar to the linear gradients we explained earlier. The CSS &lt;em&gt;url()&lt;/em&gt; function is used to apply images as a mask-image.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="masking-svg"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
overflow-x: hidden;
}
.main {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
place-items: center;
height: 100vh;
}
img {
width: 100%;
}
.masking-svg {
-webkit-mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
-webkit-mask-size: 100px;
mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
mask-size: 100px;
-webkit-mask-mode: alpha;
}
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/jOeRrYM?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYiGIyiwmuRbuo8--.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYiGIyiwmuRbuo8--.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-image&lt;/em&gt; property behaves like the background property, so when you apply a single image, it repeats itself to fill the containing element, as shown above.&lt;/p&gt;

&lt;p&gt;To fix this, the &lt;em&gt;mask-repeat&lt;/em&gt; is set to no-repeat.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-repeat property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-repeat&lt;/em&gt; CSS masking property determines the direction in which the &lt;em&gt;mask image&lt;/em&gt; should &lt;em&gt;repeat&lt;/em&gt;. This could be either vertical or horizontal. It also determines the space between the repeated mask image.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-repeat&lt;/em&gt; can be set to no-repeat to stop the mask image from repeating. Like the &lt;em&gt;background-repeat&lt;/em&gt; property, the &lt;em&gt;mask-repeat&lt;/em&gt; is set by default to repeat.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* repeat values */
-webkit-mask-repeat: repeat;
-webkit-mask-repeat: no-repeat;
-webkit-mask-repeat: space;
-webkit-mask-repeat: round;
-webkit-mask-repeat: repeat-y;
-webkit-mask-repeat: repeat-x;

/* Specifying the horizontal and Vertical repeat */
-webkit-mask-repeat: space repeat;
-webkit-mask-repeat: no-repeat round;
-webkit-mask-repeat: round space;

/*   Global Values  */
-webkit-mask-image: initial;
-webkit-mask-image: inherit;
-webkit-mask-image: revert;
-webkit-mask-image: unset;
-webkit-mask-image: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;repeat:&lt;/em&gt; sets the mask-image to repeat and fill the entire container (tile)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;no-repeat:&lt;/em&gt; stop the mask-image from repeating&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;space:&lt;/em&gt; sets the distance between the mask-image&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;round:&lt;/em&gt; sets the mask-image to stretch to fit the available space within the container&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;repeat-y:&lt;/em&gt; sets the mask-image to repeat in the y-axis (vertical)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;repeat-x:&lt;/em&gt; sets the mask-image to repeat in the x-axis (horizontal)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="main"&amp;gt;

        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="masking-svg"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .masking-svg {
        /* Chrome and other webkit browsers */
        -webkit-mask-image:   url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
      /*    Image Credit credit at tympanus.net   */
        -webkit-mask-repeat: no-repeat;
      -webkit-mask-size: 100px;

        /* Firefox */
        mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        mask-repeat: no-repeat;
    }
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/ZEqZKYN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore our in-depth guide comparing &lt;a href="https://www.lambdatest.com/learning-hub/protractor-vs-selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Protractor vs Selenium&lt;/a&gt; to make informed decisions for your test automation needs. Gain valuable insights into the key differences, advantages, and ideal use cases of these widely-used testing frameworks.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AL1PoCy9uYpXtuYcn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AL1PoCy9uYpXtuYcn.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the &lt;em&gt;no-repea*t values set the *mask-image&lt;/em&gt; to stop repeating and display just one image.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-size property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-size&lt;/em&gt; CSS masking property determines the size of the &lt;em&gt;mask-image&lt;/em&gt;. The keyword values can be used to determine a specific size ratio or multiple length values can be specified in one declaration.&lt;/p&gt;

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

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

/* Length values */
-webkit-mask-size: 500px;
-webkit-mask-size: 15rem;
-webkit-mask-size:   2em;
-webkit-mask-size:   30%;

/* Vertical and Horizontal Axes*/
-webkit-mask-size:   20%  20rem 20%;
-webkit-mask-size:   200px 10em;

/* Global Values  */
-webkit-mask-image: initial;
-webkit-mask-image: inherit;
-webkit-mask-image: revert;
-webkit-mask-image: unset;
-webkit-mask-image: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="masking-svg"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .masking-svg {
          /* Chrome and other webkit browsers */
        -webkit-mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        -webkit-mask-repeat: no-repeat;
        -webkit-mask-size: 17em;

        /* Firefox */
        mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        mask-repeat: no-repeat;
        mask-size: 17em;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/QWZPvNJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Boost Your Mobile App’s Performance! Discover Proven Strategies for &lt;a href="https://www.lambdatest.com/learning-hub/mobile-performance-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Mobile Performance Testing&lt;/a&gt;. Increase User Satisfaction &amp;amp; Rankings. Get Results Fast!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AC2b7a9GotiY2_w6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AC2b7a9GotiY2_w6h.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser preview, the mask size is increased from its initial size to 17*em*.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-position property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-position&lt;/em&gt; CSS masking property determines the position of the &lt;em&gt;mask-image&lt;/em&gt; within the container of the mask object. The mask position value is mostly specified by targeting the horizontal and vertical axes in a single declaration.&lt;/p&gt;

&lt;p&gt;The mask-position takes both length and keyword values.&lt;/p&gt;

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

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

/* Length Values */
-webkit-mask-position: 18px;
-webkit-mask-position: 4rem;
-webkit-mask-position: 8em;
-webkit-mask-position: 50%;

/* Specifying Multiple Values */
-webkit-mask-position: 50% 50%;
-webkit-mask-position: center center;
-webkit-mask-position: 4em 50%;
-webkit-mask-position: 500px center;

/* Global Values  */
-webkit-mask-image: initial;
-webkit-mask-image: inherit;
-webkit-mask-image: revert;
-webkit-mask-image: unset;
-webkit-mask-image: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="masking-svg"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .masking-svg {
        /* Chrome and other webkit browsers */
        -webkit-mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        -webkit-mask-repeat: no-repeat;
        -webkit-mask-size: 17em;
        -webkit-mask-position: center center;

        /* Firefox */
        mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        mask-repeat: no-repeat;
        mask-size: 17em;
        mask-position: center 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;iframe height="600" src="https://codepen.io/ocxigin/embed/yLRrbaW?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AeicXQZ0vOU5YyrUt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AeicXQZ0vOU5YyrUt.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This guide focuses on test automation metrics, its significance, strategies, challenges, and key &lt;a href="https://www.lambdatest.com/learning-hub/test-automation-metrics?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test automation metrics&lt;/a&gt; for measuring success.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From the browser preview, we position the &lt;em&gt;mask-image&lt;/em&gt; by specifying center center values to target both the horizontal and vertical axes in one declaration.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-origin property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-origin&lt;/em&gt; CSS masking property determines the origin of the &lt;em&gt;mask-image&lt;/em&gt;. The origin, in this case, refers to the position of the element box model.&lt;/p&gt;

&lt;p&gt;To understand how the element box model works, see the illustration below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ArC2T55G2OAqIHWOn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ArC2T55G2OAqIHWOn.png" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the &lt;em&gt;mask-origin&lt;/em&gt; can be tricky and difficult at first to wrap your head around. Make sure you specify the &lt;em&gt;mask-image&lt;/em&gt; on a block element with a closing tag. Set the background color, border, and text.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword Values */
-webkit-mask-origin: margin-box;
-webkit-mask-origin: border-box;
-webkit-mask-origin: padding-box;
-webkit-mask-origin: content-box;

/* Multiple Values */
-webkit-mask-origin: content-box, padding-box;

/* Global Values  */
-webkit-mask-origin: initial;
-webkit-mask-origin: inherit;
-webkit-mask-origin: revert;
-webkit-mask-origin: unset;
-webkit-mask-origin: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;content-box:&lt;/em&gt; set the mask-image position relative to the element content-box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;padding-box:&lt;/em&gt; set the mask-image position relative to the element padding-box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;border-box:&lt;/em&gt; set the mask-image position relative to the element border-box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;margin-box:&lt;/em&gt; set the mask-image position relative to the element margin-box.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;p&amp;gt;This is a mask-origin example: Try multiple mask origin values to see different result
            &amp;lt;/p&amp;gt;
            &amp;lt;img src="/img/cleancoding2.png" alt="" class="masking-svg"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .masking-container {
        border: 10px solid #000;
        background-color: #0ebac5;
        /* Chrome and other webkit browsers */
        -webkit-mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        -webkit-mask-repeat: repeat;
        -webkit-mask-size: 4em 4em;
        -webkit-mask-position: to top;
        -webkit-mask-origin: border-box;

        /* Firefox */
        mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/LT-black.png);
        mask-origin: border-box;
        mask-repeat: no-repeat;
        mask-size: 4em 4em;
        mask-position: center center; 
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/yLRrbMd?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Learn the ins and outs of &lt;a href="https://www.lambdatest.com/learning-hub/test-execution-engine?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution engine&lt;/a&gt;s through our extensive guide, and enhance your testing workflow with automation.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AiwGvDA50Fpf0fO74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AiwGvDA50Fpf0fO74.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the black around the logo is the border, since the mask-origin is set to border-box, the mask-origin starts positioning from the border of the element.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-composite&lt;/em&gt; CSS masking property combines two or more mask images into a single one. To combine two images into one, for example, the mask-composite based on the value provided can either &lt;em&gt;add, subtract, intersect, or exclude&lt;/em&gt; the images into one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AglsM7ik8MpW-A2hx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AglsM7ik8MpW-A2hx.png" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-composite&lt;/em&gt; CSS masking property can be beneficial when the two images being combined are shapes and must be merged to form a new shape.&lt;/p&gt;

&lt;p&gt;For accessibility and to get the desired result, PNG or SVG shapes are recommended, and for browser compatibility, Chrome does not have good support for the &lt;em&gt;mask-composite&lt;/em&gt; property, use Firefox instead.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword values */
-webkit-mask-composite: add;
-webkit-mask-composite: subtract;
-webkit-mask-composite: intersect;
-webkit-mask-composite: exclude;
/* Global Values */
-webkit-mask-image: initial;
-webkit-mask-image: inherit;
-webkit-mask-image: revert;
-webkit-mask-image: unset;
-webkit-mask-image: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;add:&lt;/em&gt; both images (png or svg shapes) are added together to form a single image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;subtract:&lt;/em&gt; the second image is subtracted from the first to form a single image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;intersect:&lt;/em&gt; both images (png or svg shapes) are intersected from the overlapping angle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;exclude:&lt;/em&gt; non-overlapping angles of both images are combined.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main class="main"&amp;gt;
        &amp;lt;!-- Section Two  --&amp;gt;
        &amp;lt;section class="masking-container"&amp;gt;
            &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" class="masking-svg"&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .masking-svg {
        /* Chrome and other webkit browsers */
        -webkit-mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/curved-triangle.svg), url(https://raw.githubusercontent.com/ocxigin/we-love-ms/f786a998033224e244ce818ae6035ce4826df85a/img/Star.svg);

        -webkit-mask-repeat: no-repeat;
        -webkit-mask-size: 17em;
        -webkit-mask-position: center center;
        -webkit-mask-origin: border-box;
        -webkit-mask-composite: add;

        /* Firefox */
        mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/curved-triangle.svg), url(https://raw.githubusercontent.com/ocxigin/we-love-ms/f786a998033224e244ce818ae6035ce4826df85a/img/Star.svg);

        mask-repeat: no-repeat;
        mask-size: 17em;
        mask-position: center center;
        mask-origin: border-box;
        mask-composite: add;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/QWZPvaP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Am4QAvtiBvt74EH8y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Am4QAvtiBvt74EH8y.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AShI-rWELee-U8wj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AShI-rWELee-U8wj4.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This guide explores &lt;a href="https://www.lambdatest.com/learning-hub/digital-transformation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Digital Transformation&lt;/a&gt;, its benefits, goals, importance and challenges involved in Digital Transformation.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  mask-clip property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-clip&lt;/em&gt; CSS masking property is used to set the area to which the mask will be applied. Depending on the value assigned to the mask-clip property, the mask can be clipped to the &lt;em&gt;margin-box&lt;/em&gt;, &lt;em&gt;border-box&lt;/em&gt;, &lt;em&gt;padding-box&lt;/em&gt;, or content-box.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2A2oVE_RMwIUjNDNtF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2A2oVE_RMwIUjNDNtF.png" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, &lt;em&gt;fill-box, stroke-box, and view-box&lt;/em&gt; are also values that determine the area mask-clip applies to, but they are used when working with SVGs.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword Values Element*/
-webkit-clip-origin: margin-box;
-webkit-clip-origin: border-box;
-webkit-clip-origin: padding-box;
-webkit-clip-origin: content-box;
-webkit-clip-origin: no-clip;

/* Keyword Values SVGs*/
-webkit-clip-origin: fill-box;
-webkit-clip-origin: view-box;
-webkit-clip-origin: stroke-box;

/* Multiple Values */
-webkit-clip-origin: content-box, padding-box;

/* Global Values  */
-webkit-clip-image: initial;
-webkit-clip-image: inherit;
-webkit-clip-image: revert;
-webkit-clip-image: unset;
-webkit-clip-image: revert-layer;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;margin-box:&lt;/em&gt; set the mask to start clipping from the margin of the box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;border-box:&lt;/em&gt; set the mask to start clipping from the box’s border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;padding-box:&lt;/em&gt; set the mask to start clipping from the padding of the box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;content-box:&lt;/em&gt; set the mask to start clipping from the box’s content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;no-clip:&lt;/em&gt; the mask is not clipped to the box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;fill-box:&lt;/em&gt; set mask to clip to the object bounding box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*fill-stroke: *set mask to clip to the object stroke bounding box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*view-box: *use the SVG view-box as a reference for clipping to the object bounding box.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card { 
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);

         /* Chrome and other webkit browsers */
        -webkit-mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/Star.svg);
        -webkit-mask-repeat: repeat;
        -webkit-mask-size: 5em;
        -webkit-mask-position: center center; 
        -webkit-mask-clip: content-box;

        /* Firefox */
        mask-image: url(https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/Star.svg);
        mask-repeat: repeat;
        mask-size: 5em;
        mask-position: center center; 
        mask-clip: content-box;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/gOQbwOX?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore our in-depth guide comparing &lt;a href="https://www.lambdatest.com/learning-hub/protractor-vs-selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Protractor vs Selenium&lt;/a&gt; to make informed decisions for your test automation needs. Gain valuable insights into the key differences, advantages, and ideal use cases of these widely-used testing frameworks.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AP5WW8u5vuG2jiVAY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AP5WW8u5vuG2jiVAY.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser preview, the &lt;em&gt;mask-clip&lt;/em&gt; is clipped starting from the content of the box. However, to see how the &lt;em&gt;mask-clip&lt;/em&gt; works, try experimenting with other values of the &lt;em&gt;mask-clip&lt;/em&gt; CSS masking property.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-type property
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-type&lt;/em&gt; CSS masking property is used to determine the CSS masking type (mode) of the &amp;lt;&lt;em&gt;mask&lt;/em&gt;&amp;gt; element. The mask-type is based on two values which are *luminance *and alpha.&lt;/p&gt;

&lt;p&gt;The values (&lt;em&gt;luminance and alpha&lt;/em&gt;) specified on the mask will determine how the &lt;em&gt;mask element&lt;/em&gt; will render. However, the &lt;em&gt;mask-mode&lt;/em&gt; property overrides the value set on the &lt;em&gt;mask-type&lt;/em&gt; CSS masking property. For example, if the &lt;em&gt;mast-type&lt;/em&gt; initial value is &lt;em&gt;luminance&lt;/em&gt;, the &lt;em&gt;mask-mode&lt;/em&gt; can be set to *alpha *to override it.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword values */
-webkit-mask-type: luminance;
-webkit-mask-type: alpha;

/* Global Values  */
-webkit-mask-type: initial;
-webkit-mask-type: inherit;
-webkit-mask-type: revert;
-webkit-mask-type: unset;
-webkit-mask-type: revert-layer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;em&gt;mask-type&lt;/em&gt; property directly applies to the mask element and has two values namely &lt;em&gt;luminance *and *alpha&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Ao3vaMrxPsrODmuL_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Ao3vaMrxPsrODmuL_.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source- drafts.fxtf.org&lt;/p&gt;

&lt;h3&gt;
  
  
  alpha
&lt;/h3&gt;

&lt;p&gt;The alpha refers to the transparent part of an image (PNG) which is called the alpha channel. The alpha channel is the fourth channel of an image that supports transparency. The other three are &lt;em&gt;Red, Green, and Blue&lt;/em&gt;, respectively, and are mostly referred to as RGB. However, the alpha channel it’s called &lt;em&gt;RGBA&lt;/em&gt;, the “&lt;em&gt;A&lt;/em&gt;” being the alpha channel (transparency).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A-lFib9KWYjzxV0PO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A-lFib9KWYjzxV0PO.png" width="745" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source- vectornator.io&lt;/p&gt;

&lt;p&gt;Images that support or have alpha channels are PNG images (PSD, TGA, DDS, or TIFF also support alpha channels). Images such as JPG (jpeg) do not have an alpha channel, and as a result, transparency can not be applied to it.&lt;/p&gt;

&lt;p&gt;An image’s alpha channel does not have color information aside from black and white. The black is used to completely hide content by masking it, while the white is used to show hidden mask content.&lt;/p&gt;

&lt;p&gt;The degree of the alpha channel can be present as opacity, and it ranges from 0.0 to 1. Where 0 means complete transparency, and one (1) means opaque. The values can also be specified as 0.5, which means the object should be slightly translucent. This is very common when defining the &lt;em&gt;box-shadow&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALaSwS1GCIqrwB4B9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALaSwS1GCIqrwB4B9.png" width="564" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The alpha channel is very useful when you want to mask out an image or apply transparency so that you can see through an element or image.&lt;/p&gt;

&lt;p&gt;And in the case of CSS masking, when we use &lt;em&gt;alpha&lt;/em&gt;, it’s to hide or show the specified mask element or image.&lt;/p&gt;

&lt;p&gt;In the absence of alpha, luminance can be used.&lt;/p&gt;

&lt;h3&gt;
  
  
  luminance
&lt;/h3&gt;

&lt;p&gt;The luminance value specifies that the luminance of the &lt;em&gt;mask-image&lt;/em&gt; or element mask should be used instead of the transparent alpha value.&lt;/p&gt;

&lt;p&gt;This value can be a solid black, white, or faded mask which is a computed value from the alpha channel and the image or element RGB value specified on the object.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 255.26 242.77"&amp;gt;

&amp;lt;mask id="maskExmaple"&amp;gt;
    &amp;lt;polygon points="127.63 0 165.74 81.75 255.26 92.73 189.29 154.23 206.51 242.77 127.63 199.03 48.75 242.77 65.97 154.23 0 92.73 89.52 81.75 127.63 0" fill="black"/&amp;gt;
    &amp;lt;/mask&amp;gt;
&amp;lt;/svg&amp;gt;

&amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt="" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
    display: grid;
    place-items: center;
    height: 100vh;
    background: #0ebac5;
}

svg {
    display: block;
    width: 100px;
    height: 100px;
}

img {
    display: block;
    width: 100%;
    max-width: 450px;
    margin: auto;
    -webkit-mask-image: url(#maskExmaple);
    mask-image: url(#maskExmaple);
}

mask {
    -webkit-mask-type:alpha;
    mask-type: alpha;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It’s important to note that as at the time of writing, the support of &lt;em&gt;mask *property is not that great in Chrome and might not show on your browser due to browser compatibility issues. Try using Firefox instead.&lt;br&gt;
**Output&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/GRwgMxb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Boost Your Mobile App’s Performance! Discover Proven Strategies for &lt;a href="https://www.lambdatest.com/learning-hub/mobile-performance-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Mobile Performance Testing&lt;/a&gt;. Increase User Satisfaction &amp;amp; Rankings. Get Results Fast!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Ai_7LPhB6im0rmRrD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Ai_7LPhB6im0rmRrD.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the *alpha *value specified in the CSS masking property is used to display the star object mask that is hidden with the *black *fill specified on the SVG polygon tag in the HTML file.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-mode
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-mode&lt;/em&gt; CSS masking property is used to override the value set on the &lt;em&gt;mask-type&lt;/em&gt; property. For example, if the &lt;em&gt;mast-type&lt;/em&gt; initial value is &lt;em&gt;alpha&lt;/em&gt;, the &lt;em&gt;mask-mode&lt;/em&gt; can be set to *luminance *to override it.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-mode&lt;/em&gt; CSS masking property takes three values: &lt;em&gt;luminance, alpha, and match-source.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Unlike the &lt;em&gt;luminance *and *alpha *value, which are very specific, the *match-source&lt;/em&gt;, depending on the source of the object, is used as a mask. If SVG is used as a mask, the SVG &lt;em&gt;luminance *value should be used as a mask on the image layer. However, if &amp;lt;*image&lt;/em&gt;&amp;gt; is used as a mask, the alpha value of the image should be used as a mask on the image layer.&lt;/p&gt;

&lt;p&gt;From the previous example, we have an SVG as a mask, and we previously set it to alpha, and we set the polygon fill to black in the HTML file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AiA12KqTpMJKbAK8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AiA12KqTpMJKbAK8h.png" width="604" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see how the &lt;em&gt;mask-mode&lt;/em&gt; and &lt;em&gt;luminance work&lt;/em&gt;, change the fill in polygon to orange (you can use any color of your choice) and then set the &lt;em&gt;mask-mode&lt;/em&gt; to luminance in the CSS file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AcIuk9liYCZiZQsjS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AcIuk9liYCZiZQsjS.png" width="301" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your browser output should be like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AhQvDN06nA-h6e3ta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AhQvDN06nA-h6e3ta.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser preview, we have a slightly faded mask compared to the previous example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Border Box Mask
&lt;/h2&gt;

&lt;p&gt;Let us further discuss the properties of border box masks.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-border
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border&lt;/em&gt; CSS masking property is used to set the border mask image on a specified element. The &lt;em&gt;mask-border&lt;/em&gt; property is a shorthand property and has the following longhand properties.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-border-source&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-border-slice&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-border-mode&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-border-width&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-border-outset&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;m*ask-border-repeat*&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When in use, the &lt;em&gt;mask-border&lt;/em&gt; CSS masking property masks the edges of the specified element’s border, then the image is split into nine sections or regions by the m*ask-border-slice* property.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;mask-border-slice&lt;/em&gt; controls how the image is divided into regions depending on the values provided; it can also act like a background with the &lt;em&gt;fill value&lt;/em&gt;. However, the other longhand properties are used to style the image that has been sliced.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  /* source | slice | width | outset | repeat | mode */
mask-border: url("icon-star.png") 25 / 35px / 12px space alpha;

  /* Global Values */
-webkit-mask-border: initial;
-webkit-mask-border: inherit;
-webkit-mask-border: revert;
-webkit-mask-border: unset;
-webkit-mask-border: revert-layer;
    }
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;At the time of writing this blog, the mask-border shorthand and longhand property is not supported yet in major browsers and as a result requires the use of non-standard property on Chromium-based browsers for testing. These properties include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-box-image-source&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-box-image-repeat&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-box-image-width&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-box-image-outset&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;mask-box-image-mode&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Mask-box-image-slice&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above non-standard properties can be used as a replacement for testing purposes when working with *mask-border *longhand properties.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2APRx53q3FRxIW8Ukp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2APRx53q3FRxIW8Ukp.png" width="800" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://caniuse.com/?search=mask-border" rel="noopener noreferrer"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Firefox section is completely red, indicating NOT support in all Firefox versions. Chrome and other Chromium-based browsers support an outdated version of this property.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This guide focuses on &lt;a href="https://www.lambdatest.com/learning-hub/test-automation-metrics?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test automation metrics&lt;/a&gt;, its significance, strategies, challenges, and key test automation metrics for measuring success.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  mask-border-source
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border-source&lt;/em&gt; CSS masking property is a longhand property of the &lt;em&gt;mask-border&lt;/em&gt; property. It is used to set the mask-border-image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Specified Values */
mask-border-source: url("icon-star.png");
mask-border-source: linear-gradient(to bottom, cyan, darkcyan);

/* Global Values */
-webkit-mask-border-source: initial;
-webkit-mask-border-source: inherit;
-webkit-mask-border-source: revert;
-webkit-mask-border-source: unset;
-webkit-mask-border-source: revert-layer;
}

/* Non Standard Property */
-webkit-mask-box-image-source: initial;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The non-standard property for &lt;em&gt;mask-border-source&lt;/em&gt; is &lt;em&gt;mask-box-image-source&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here is a preview of the image we will be using:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A0NsB-0m8MTxq3NvO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A0NsB-0m8MTxq3NvO.png" width="640" height="72"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is a 52 x 49 dimension png image. Now type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card mask"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card 
        { 
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    }

  .mask {
      -webkit-mask-box-image-source: url(https://user-images.githubusercontent.com/78242022/244883515-a1210117-14e5-4145-9b8d-96095939dfd3.png);
}
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/ExOjgvj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2528%2F0%2Aw_IY-4b5vSibpG-M.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2528%2F0%2Aw_IY-4b5vSibpG-M.png" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the image is rendered as a fill, you will learn how to split and repeat the image in the section below.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-border-repeat
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border-repeat&lt;/em&gt; CSS masking property is a longhand property of the &lt;em&gt;mask-border&lt;/em&gt; property. It is used to adjust the scale to fit the &lt;em&gt;mask-border-image&lt;/em&gt; dimension.&lt;/p&gt;

&lt;p&gt;The non-standard property for &lt;em&gt;mask-border-repeat&lt;/em&gt; is &lt;em&gt;mask-box-image-repeat&lt;/em&gt;. Like the first example, we will use it to test how the &lt;em&gt;mask-border-repeat&lt;/em&gt; functions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword value */
-webkit-mask-border-repeat: stretch;
-webkit-mask-border-repeat: repeat;
-webkit-mask-border-repeat: round;
-webkit-mask-border-repeat: space;

/* Global Values */
-webkit-mask-border-repeat: initial;
-webkit-mask-border-repeat: inherit;
-webkit-mask-border-repeat: revert;
-webkit-mask-border-repeat: unset;
-webkit-mask-border-repeat: revert-layer;

/* Non Standard Property */
-webkit-mask-box-image-repeat: round;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;stretch:&lt;/em&gt; stretched to fill the gap between the mask-border-image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;repeat:&lt;/em&gt; adjust and scale the source image around the element’s border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;round:&lt;/em&gt; adjust and round the source image around the element’s border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;space:&lt;/em&gt; adjust and apply spaces between the source image and the element border.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now type and run the code below to see how this works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card mask"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card
        {
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    }

    .mask {
        -webkit-mask-box-image-source:  url(https://user-images.githubusercontent.com/78242022/244883515-a1210117-14e5-4145-9b8d-96095939dfd3.png);

        -webkit-mask-box-image-repeat: repeat;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/MWzwbKa?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Learn the ins and outs of &lt;a href="https://www.lambdatest.com/learning-hub/test-execution-engine?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution engines&lt;/a&gt; through our extensive guide, and enhance your testing workflow with automation.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2528%2F0%2AJxAnGwbyWWvYfA-l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2528%2F0%2AJxAnGwbyWWvYfA-l.png" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we applied the repeat value, which repeats the source image around the element’s border.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-border-slice
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border-slice&lt;/em&gt; CSS masking property is a longhand property of the &lt;em&gt;mask-border property&lt;/em&gt;, it is used to slice the image parsed by the &lt;em&gt;mask-border-source&lt;/em&gt; into nine pieces, and these pieces are grouped in four corners, four edges, and a middle region.&lt;/p&gt;

&lt;p&gt;The image below illustrates how the regions are distributed by their distance and size. The red is used to specify this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AxZpx8lq5drWSq2Qi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AxZpx8lq5drWSq2Qi.png" width="667" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*Source- *developer.mozilla.&lt;/p&gt;

&lt;p&gt;How the regions are organized is explained below&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The 1,2,3, and 4 boxes (zones) are the corners of the source image. This forms the corners of the mask-border image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The 5,6,7 and 8 boxes (zones) are used to form the edges. They are mostly repeated or scaled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The 9 box is the center of the region and is mostly discarded except if specified by the &lt;em&gt;fill&lt;/em&gt; property.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;mask-border-outset, mask-border-width&lt;/em&gt;, and &lt;em&gt;mask-border-repeat&lt;/em&gt; are used to modify the final render of the slice zones.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword value */
-webkit-mask-border-slice: fill;

/* length value */
-webkit-mask-border-slice: 12;

/* Percentage value */
-webkit-mask-border-slice: 20%;

/* Global Values */
-webkit-mask-border-slice: initial;
-webkit-mask-border-slice: inherit;
-webkit-mask-border-slice: revert;
-webkit-mask-border-slice: unset;
-webkit-mask-border-slice: revert-layer;

/* Non Standard Property */
-webkit-mask-box-image-slice: 12;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The non-standard property for &lt;em&gt;mask-border-slice&lt;/em&gt; is &lt;em&gt;mask-box-image-slice&lt;/em&gt;. Just like the other examples, we are going to be using it to test how the &lt;em&gt;mask-border-slice&lt;/em&gt; functions.&lt;/p&gt;

&lt;p&gt;Try the code sample below&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card mask"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card 
        { 
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    }

    .mask {
        -webkit-mask-box-image-source: url(https://user-images.githubusercontent.com/78242022/244883515-a1210117-14e5-4145-9b8d-96095939dfd3.png);

        -webkit-mask-box-image-repeat: repeat;
        -webkit-mask-box-image-slice: 12 20%;

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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/gOQpLQN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A-oPSlasUo6l1iqsJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A-oPSlasUo6l1iqsJ.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we remove the center region and slice the &lt;em&gt;top and bottom&lt;/em&gt; by &lt;em&gt;12&lt;/em&gt; and the &lt;em&gt;left&lt;/em&gt; and &lt;em&gt;right&lt;/em&gt; by &lt;em&gt;20%&lt;/em&gt; (percent).&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-border-outset
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border-outset&lt;/em&gt; CSS masking property is a longhand property of the &lt;em&gt;mask-border&lt;/em&gt; property; it is used to set the distance between the &lt;em&gt;border-box&lt;/em&gt; and the element &lt;em&gt;mask-border&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The non-standard property for &lt;em&gt;mask-border-outset&lt;/em&gt; is &lt;em&gt;mask-box-image-outset&lt;/em&gt;. We are going to be using it to test how the &lt;em&gt;mask-border-outset&lt;/em&gt; functions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Number value */
-webkit-mask-border-outset: 5;

/* length value */
-webkit-mask-border-outset: 1.2rem;

/* Percentage value */
-webkit-mask-border-outset: 20%;

/* Global Values */
-webkit-mask-border-outset: initial;
-webkit-mask-border-outset: inherit;
-webkit-mask-border-outset: revert;
-webkit-mask-border-outset: unset;
-webkit-mask-border-outset: revert-layer;

/* Non Standard Property */
-webkit-mask-box-image-outset: 20%;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card mask"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card
        {
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    }

    .mask {
        -webkit-mask-box-image-source: url(https://user-images.githubusercontent.com/78242022/244883515-a1210117-14e5-4145-9b8d-96095939dfd3.png);

        -webkit-mask-box-image-repeat: repeat;
        /* -webkit-mask-box-image-slice: 12 20%; */
        -webkit-mask-box-image-outset: 1rem;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/XWybNvZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This guide explores Digital Transformation, its benefits, goals, importance and challenges involved in &lt;a href="https://www.lambdatest.com/learning-hub/digital-transformation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Digital Transformation&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AO8odcHZ3fn47RUXM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AO8odcHZ3fn47RUXM.png" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, a length value of 1rem is set on the outset of the mask-border. The &lt;em&gt;1rem&lt;/em&gt; is applied on all four corners of the zones. If two values were provided, such as &lt;em&gt;1rem 12&lt;/em&gt;, they will be applied to the &lt;em&gt;top-bottom and left-right&lt;/em&gt;, respectively. However, it follows the anticlockwise direction in CSS together with properties like &lt;em&gt;margin and padding&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-border-width
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border-outset&lt;/em&gt; CSS masking property is a longhand property of the &lt;em&gt;mask-border&lt;/em&gt; property. It is used to determine the width of the element’s border-mask.&lt;/p&gt;

&lt;p&gt;The non-standard CSS masking property for &lt;em&gt;mask-border-width&lt;/em&gt; is &lt;em&gt;mask-box-image-width&lt;/em&gt;. We are going to be using it to test how the &lt;em&gt;mask-border-width&lt;/em&gt; functions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword value */
-webkit-mask-border-width: auto;

/* Number value */
-webkit-mask-border-width: 5;

/* length value */
-webkit-mask-border-width: 1.2rem;

/* Percentage value */
-webkit-mask-border-width: 20%;

/* top | right | bottom | left */
mask-border-width: 1em 10px 5% auto;

/* Global Values */
-webkit-mask-border-width: initial;
-webkit-mask-border-width: inherit;
-webkit-mask-border-width: revert;
-webkit-mask-border-width: unset;
-webkit-mask-border-width: revert-layer;

/* Non Standard Property */
-webkit-mask-box-image-width: 1em 20%;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card mask"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card
        {
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    }

    .mask {
        -webkit-mask-box-image-source: url(https://user-images.githubusercontent.com/78242022/244883515-a1210117-14e5-4145-9b8d-96095939dfd3.png);

  -webkit-mask-box-image-repeat: repeat;
        -webkit-mask-box-image-outset: 1rem;
        -webkit-mask-box-image-width: 1rem 20%;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/vYQOgKo?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmBHMCzC10R65HNgY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmBHMCzC10R65HNgY.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we reduce the width by 1rem top and bottom and 20% left and right.&lt;/p&gt;

&lt;h2&gt;
  
  
  mask-border-mode
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;mask-border-mode CSS&lt;/em&gt; masking property is a longhand property of the &lt;em&gt;mask-border&lt;/em&gt; property; it is used to set the blending mode of the element’s border-mask.&lt;/p&gt;

&lt;p&gt;The non-standard property for &lt;em&gt;mask-border-mode&lt;/em&gt; is &lt;em&gt;mask-box-image-mode&lt;/em&gt;. We are going to be using it to test how the &lt;em&gt;mask-border-mode&lt;/em&gt; functions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Keyword values */
-webkit-mask-border-mode: luminance;
-webkit-mask-border-mode: alpha;

/* Global Values */
-webkit-mask-border-mode: initial;
-webkit-mask-border-mode: inherit;
-webkit-mask-border-mode: revert;
-webkit-mask-border-mode: unset;
-webkit-mask-border-mode: revert-layer;

/* Non Standard Property */
-webkit-mask-box-image-mode: luminance;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="main"&amp;gt;
    &amp;lt;!-- No Effect --&amp;gt;
    &amp;lt;section class="card mask"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950813-021da2fc-cdf3-4409-9b0e-cbb73db6fd0c.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Clean Coding Practices for Test Automation: Part 2&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;In this webinar, we learned about the clean coding practices with real-world scenarios and showcased the implementation of various design patterns.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; body {
        overflow-x: hidden;
    }

    .main {
        display: grid;
        grid-template-columns:1fr;
        grid-template-rows: auto;
        place-items: center;
        height: 100vh;
    }

    img {
        width: 100%;
    }

    .card
        {
            background-color: wheat;
            font-family: calibri;
            font-size: 18px;
            width: 300px;
            height: fit-content;
            border: 5px solid #0ebac5;
            padding: 20px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    }

    .mask {
        -webkit-mask-box-image-source: url(https://user-images.githubusercontent.com/78242022/244883515-a1210117-14e5-4145-9b8d-96095939dfd3.png);

        -webkit-mask-box-image-repeat: round space;
        -webkit-mask-box-image-outset: 1rem;
        -webkit-mask-box-image-mode: luminance;
    }
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/eYQNgyj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3s4dhqRxt9QOYCPs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3s4dhqRxt9QOYCPs.png" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the mask-border is set to a blend mode of &lt;em&gt;luminance&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML SVG Mask Element
&lt;/h2&gt;

&lt;p&gt;We have covered what CSS masking is and the CSS masking properties. We’ve also covered the border box mask, the mask-border and mask-border longhand properties, what they are, and how to use them.&lt;/p&gt;

&lt;p&gt;In this section, we will learn how to use the HTML SVG &amp;lt; mask &amp;gt; element and how to create stunning effects using text and Custom SVGs (Scalable Vector Graphics).&lt;/p&gt;

&lt;h2&gt;
  
  
  Mask video with text
&lt;/h2&gt;

&lt;p&gt;We will be creating a text that masks through a video, and the video plays in the background.&lt;/p&gt;

&lt;p&gt;And by the end of this project, you should know how to work with the SVG &amp;lt; mask &amp;gt; element and use it in your project.&lt;/p&gt;

&lt;p&gt;Let’s begin.&lt;/p&gt;

&lt;p&gt;Here is what the complete project demo looks like.&lt;/p&gt;

&lt;p&gt;Firstly, create an HTML file and type the code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;video loop autoplay muted preload playinline class="video-tag"&amp;gt;
        &amp;lt;source src="https://user-images.githubusercontent.com/78242022/241950930-5b89bd67-4299-4ca0-883e-8273b745c054.mp4"/&amp;gt;
    &amp;lt;/video&amp;gt;

    &amp;lt;svg width="100%" height="100%"&amp;gt;
        &amp;lt;defs&amp;gt;
            &amp;lt;mask id="myText" width="100%" height="100%" x="0" y="0"&amp;gt;
                &amp;lt;rect width="100%" height="100%" x="0" y="0" /&amp;gt;
                &amp;lt;text x="50%" y="50%" fill="plum" text-anchor="middle"&amp;gt;LambdaTest&amp;lt;/text&amp;gt;
            &amp;lt;/mask&amp;gt;
        &amp;lt;/defs&amp;gt;
        &amp;lt;rect width="100%" height="100%" x="0" y="0" /&amp;gt;
    &amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import url('https://fonts.googleapis.com/css2?family=Bowlby+One+SC&amp;amp;family=Koulen&amp;amp;family=Luckiest+Guy&amp;amp;display=swap');
    html {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    body {
        font-family: 'Bowlby One SC','Koulen','Luckiest Guy', cursive;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }

    video {
        width: 100%;
        height: 100%;
    }

    svg {
        font-size: 8em;
        font-family: "Arial";
      font-weight: 900;
      text-transform: uppercase;
        transition: all 0.5s linear;
        position: absolute;
        inset: 0;
        height: 100%;
    }

    svg rect {
        fill: #fff;
        mask: url(#myText);
    }

    /* Media Query */
    @media screen and (max-width: 745px) {
        svg {
        font-size: 5em;
    }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, save your CSS file and open it on the browser, your browser preview should be just like this.&lt;/p&gt;

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

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/LYgvpwv?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AuYQNxUBGnTJxRA0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AuYQNxUBGnTJxRA0g.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser preview, the SVG &amp;lt; mask &amp;gt; is used to create an alpha mask to mask on the video and text. To mask the text show, we add a fill color of #&lt;em&gt;fff&lt;/em&gt; (white).&lt;/p&gt;

&lt;p&gt;As stated earlier, the white is for showing hidden mask content by a &lt;em&gt;black&lt;/em&gt; mask.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mask video with Custom SVG
&lt;/h2&gt;

&lt;p&gt;Now that you have a better understanding of how to work with SVG &lt;em&gt;&amp;lt; mask &amp;gt;&lt;/em&gt; tag. Let’s take our little project a bit further and more interesting by adding a custom SVG logo or shape.&lt;/p&gt;

&lt;p&gt;Here is what the project demo looks like:&lt;/p&gt;

&lt;p&gt;From the same project folder, create a new html file and give it any name of your choice.&lt;br&gt;
I will call mine “&lt;em&gt;shape.html&lt;/em&gt;”.&lt;/p&gt;

&lt;p&gt;Next, type the HTML code in your text editor and open it in your browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AQYYG7yJnl9pI9G-H.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AQYYG7yJnl9pI9G-H.png" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;video loop autoplay muted preload playinline class="video-tag"&amp;gt;
        &amp;lt;source src="https://user-images.githubusercontent.com/78242022/241950930-5b89bd67-4299-4ca0-883e-8273b745c054.mp4"/&amp;gt;
    &amp;lt;/video&amp;gt;

    &amp;lt;svg width="100%" height="100%"&amp;gt;
        &amp;lt;defs&amp;gt;
            &amp;lt;mask id="myText" width="100%" height="100%" x="0" y="0"&amp;gt;
                &amp;lt;rect width="100%" height="100%" x="0" y="0" /&amp;gt;
               &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 348.12 393.18"&amp;gt;
  &amp;lt;path d="M247.96,38.68c-3.47-1.99-6.84-4.13-10.41-5.97-3.04-1.56-5.92-3.52-8.85-5.33-1.58-.97-3.4-1.55-4.77-2.9-.69-.69-1.93-.18-2.58-.85-1.75-1.79-4.06-2.7-6.05-4.09-2.48-1.73-5.29-2.84-7.86-4.38-1.26-.75-2.49-1.54-3.76-2.28-2.99-1.75-6.09-3.29-9.11-4.97-1.86-1.04-3.43-2.59-5.41-3.56-3.52-1.72-7-3.31-10.95-3.96-4.51-.75-8.87-.41-13.06,1.12-3.54,1.29-7.02,2.83-10.02,5.29-1.92,1.58-4.24,2.58-6.51,3.63-2.14,.99-4.01,2.43-6.04,3.61-3.9,2.27-7.78,4.58-11.77,6.7-1.04,.55-1.99,1.26-2.94,1.95-2.02,1.46-4.41,2.2-6.53,3.44-1.35,.79-2.58,1.8-3.94,2.58-3.13,1.79-6.43,3.31-9.43,5.29-3.64,2.4-7.51,4.4-11.19,6.74-3.17,2.01-6.57,3.72-9.89,5.51-2.62,1.41-5.33,2.77-7.54,4.85-.23,.22-.44,.41-.8,.52-3.48,1.05-6.24,3.42-9.36,5.12-2.69,1.46-5.22,3.26-8.12,4.33-.18,.07-.35,.23-.47,.34-2.51,2.18-5.68,3.3-8.35,5.2-.45,.32-.95,.62-1.47,.81-1.42,.51-2.78,.95-3.84,2.23-.37,.45-1.51,.75-2.15,1.13-2.99,1.81-6.1,3.42-9.08,5.24-2.04,1.24-3.97,2.77-6.32,3.52-1.17,.38-2.01,1.38-3.1,1.96-5.24,2.78-10.23,6-15.36,8.97-1.88,1.09-2.97,3.03-4.59,4.39-2.54,2.15-3.48,5.28-5.05,8.02-.4,.69-.34,1.54-.45,2.29-.6,4.16-1.07,8.35-.71,12.57,.03,.38,0,.76,0,1.14,0,56.14-.01,112.29,.03,168.43,0,2.92,.99,5.68,2.24,8.34,1.84,3.93,4.66,7.05,8.06,9.58,2.6,1.93,5.23,3.91,8.3,5.1,.93,.36,1.53,1.08,2.3,1.62,1.13,.8,2.43,1.34,3.73,1.84,.77,.3,1.52,.66,2.14,1.28,1.77,1.77,4.12,2.7,6.25,3.83,2.18,1.16,4.21,2.69,6.65,3.35,.24,.06,.34,.21,.48,.34,3.81,3.51,8.75,5.2,13.01,8.02,2.9,1.92,6.04,3.72,9.33,5.15,2.19,.95,4.12,2.65,6.27,3.78,3.2,1.68,6.17,3.73,9.4,5.37,2.47,1.26,4.91,2.74,7.23,4.32,2.03,1.38,4.49,2.07,6.2,3.92,.35,.38,.82,.45,1.16,.44,1.1-.03,1.8,.44,2.29,1.35,.19,.36,.47,.61,.82,.82,3.76,2.33,7.47,4.77,11.29,6.99,2.66,1.55,9.13,1.47,12.45-1.04,3.32-2.51,4.31-5.78,4.33-9.55,.07-11,.07-22,0-33-.02-2.67-.97-5.2-1.93-7.68-.25-.64-.74-1.08-1.29-1.48-.94-.7-1.93-1.38-2.3-2.6-.12-.41-.43-.64-.81-.82-4.93-2.39-9.49-5.42-14.21-8.18-2.36-1.38-4.9-2.49-7.15-3.97-4.68-3.09-9.76-5.48-14.45-8.55-2.97-1.94-6.19-3.51-9.28-5.27-1-.57-2.01-1.13-2.93-1.81-1.22-.89-2.59-1.47-3.89-2.18-2.27-1.24-4.83-2.06-6.59-4.16-.74-.88-1.84-1.28-2.92-1.65-3.24-1.13-3.63-2.14-3.72-5.39-.44-15.79-.17-31.58-.19-47.38-.04-27.28-.02-54.57,.01-81.85,0-2.12,.1-4.25,.15-6.37,.05-2.01,1.15-3.34,2.92-4.26,3.96-2.06,7.87-4.22,11.63-6.65,1.81-1.17,3.63-2.39,5.69-3.15,1.81-.67,3.21-2.04,4.89-2.96,4.41-2.41,8.88-4.76,13.04-7.56,3.11-2.09,6.69-3.28,9.68-5.5,3.45-2.56,7.37-4.34,11.02-6.58,2.7-1.67,5.49-3.26,8.26-4.85,7.05-4.04,14.1-8.08,21.06-12.28,2.45-1.48,5.11-2.52,7.44-4.29,2.4-1.82,5.36-2.88,7.92-4.53,2.56-1.64,5.42-2.71,7.88-4.52,3.06-2.25,6.67-3.55,9.97-5.38,.25-.14,.74-.13,1.14,.12,3.69,2.35,7.58,4.35,11.33,6.6,3.05,1.83,6.11,3.73,9.35,5.3,1.99,.96,4.06,2.04,5.83,3.58,1.48,1.28,3.45,1.99,5.17,3.01,3.39,1.99,6.67,4.2,10.17,5.97,2.13,1.08,4.25,2.25,6.27,3.45,2.75,1.62,5.53,3.24,8.28,4.87,3.92,2.32,7.78,4.77,11.87,6.8,1.51,.75,2.7,2.06,4.26,2.75,3.44,1.53,6.45,3.81,9.71,5.59,3,1.64,5.87,3.55,9.02,4.99,2.31,1.05,4.38,2.81,6.63,4.05,2.55,1.4,4.82,3.41,7.79,4.03,.36,.07,.73,.36,.97,.64,2.08,2.4,5.2,3.14,7.71,4.85,1.33,.91,2.8,1.64,4.36,2.22,1.53,.58,1.83,2.14,1.83,3.7-.01,8.39,0,16.77,0,25.16,0,6.26-.04,12.53,.02,18.79,.03,3.16,1.5,5.63,3.89,7.7,4.98,4.32,11.18,6.68,16.59,10.33,2.9,1.95,6.22,3.43,9.37,5.07,1.56,.81,2.76,2.27,4.43,3.07,3.41,1.65,6.9,2.56,10.63,1.42,1.92-.59,3.66-1.46,4.95-3.22,1.85-2.53,2.58-5.3,2.58-8.36,0-26.14,.01-52.28-.02-78.42,0-3.94-.79-7.78-2.66-11.24-1.28-2.38-2.25-5.07-4.82-6.61-.96-.58-1.7-1.56-2.45-2.43-.36-.42-.63-.94-1.17-1.12-2.57-.86-4.59-2.81-7.18-3.62-.41-.13-.8-.34-1.16-.63-2.53-2.09-5.61-3.29-8.3-5.11-1.91-1.3-4-2.3-5.98-3.43-2.22-1.27-4.37-2.73-6.72-3.86-2.77-1.33-5.42-3.1-8.08-4.74-2.68-1.65-5.39-3.25-8.18-4.71-1.11-.58-2.06-1.33-3.08-2-2.4-1.56-4.98-2.77-7.52-4.08-2.72-1.41-5.14-3.29-7.83-4.77-1.14-.62-2.18-1.44-3.45-1.74-.32-.08-.62-.23-.79-.38-2.4-2.16-5.36-3.49-8.09-5.1-2.49-1.47-5-3.01-7.74-4.13-1.66-.68-3.11-2.05-4.78-2.91" width="70%" height="70%"/&amp;gt;
  &amp;lt;path d="M173.46,163.82c-3.43-2.3-7.02-4.35-10.63-6.36-2.82-1.57-5.62-3.16-8.37-4.84-1.91-1.17-3.88-2.33-5.99-3.19-2.03-.83-3.75-2.31-5.45-3.56-1.66-1.22-3.45-1.69-5.18-2.44-3.15-1.37-6.45-1.55-9.79-.84-1.67,.35-3.28,1.07-4.69,1.88-2.3,1.33-4.64,2.63-6.83,4.21-1.46,1.06-3.25,1.94-4.97,2.75-1.88,.87-3.72,1.83-5.4,3.08-1.52,1.12-3.07,2.15-4.88,2.83-1.47,.55-2.77,1.56-4.08,2.44-2.6,1.76-5.56,2.85-8.24,4.46-1.74,1.05-3.42,2.17-4.81,3.55-2.72,2.7-5.07,5.7-4.79,9.92,.17,2.46-.5,5.02,.69,7.34,1.28,2.52,2.38,5.12,3.87,7.55,1.4,2.28,2.81,4.57,3.95,7.01,.78,1.66,2.27,2.88,2.92,4.58,1.43,3.77,4.45,6.02,7.74,7.76,3.73,1.98,7.76,2.19,11.91,.79,1.99-.67,3.78-1.68,5.49-2.74,2.74-1.71,5.69-3.03,8.41-4.77,1.83-1.17,3.48-2.69,5.66-3.38,1.48-.47,2.72-.68,4.11,.2,3.02,1.91,6.07,3.76,9.15,5.55,1.18,.69,2.55,1.01,3.59,1.97,.98,.9,1.49,1.86,1.49,3.28-.04,54.67-.03,109.35-.03,164.02,0,2.09,.56,4.12,.73,6.2,.08,1.08,1.01,2.04,1.73,2.94,1.57,1.95,3.32,3.64,5.52,4.95,4.75,2.83,9.59,2.8,14.55,.91,1.23-.47,2.28-1.35,3.37-2.13,2.01-1.44,3.64-3.27,5.61-4.73,2.18-1.61,4.45-3.1,6.43-5,1.64-1.57,3.46-2.98,5.33-4.33,2.69-1.94,5.35-4.06,7.14-6.87,1.23-1.93,1.92-4.26,2.04-6.65,.35-7.4,.07-14.81,.16-22.22,.38-31.58,.06-63.17,.16-94.75,0-2.61,0-2.61,.91-3.53,2.36,1.49,5.01,2.53,7.29,4.3,1.78,1.38,3.94,2.25,5.83,3.5,1.9,1.26,3.98,2.19,5.95,3.31,2.54,1.45,4.86,3.24,7.59,4.42,2.55,1.1,4.96,2.64,7.22,4.34,.43,.33,.78,.77,1.31,.97,3.97,1.51,7.38,3.98,10.97,6.16,2.49,1.51,5.15,2.76,7.67,4.26,2.45,1.46,4.87,2.99,7.32,4.47,.59,.35,1.07,.75,1.81,.81,2.18,.18,3.3,2.15,5.04,3.12,4.02,2.24,8.03,4.51,12.06,6.75,2.44,1.35,4.94,2.69,7.24,4.31,2.54,1.79,5.34,3.16,7.99,4.76,3.59,2.17,7.31,4.12,10.96,6.19,4.32,2.45,8.7,3.4,13.59,1.4,2.27-.93,4.17-2.08,6.06-3.62,3.29-2.69,5.67-6.22,8.79-9.02,1.56-1.4,2.85-3.07,4.43-4.39,1.78-1.48,3.29-3.22,4.62-5.01,1.47-1.97,2.4-4.33,2.38-6.97-.05-9.97-.01-19.93-.02-29.9,0-2.69-1.18-4.96-2.97-6.83-1.32-1.38-2.94-2.43-4.68-3.35-4.11-2.18-8.05-4.69-12.13-6.95-2.69-1.49-5.2-3.27-7.97-4.65-1.65-.82-3.13-1.99-4.75-2.91-1.92-1.09-3.99-1.73-6.06-2.42-1.63-.54-3.25-.48-4.9-.02-1.75,.5-3.77,.97-4.95,2.08-1.68,1.59-3.11,3.66-3.72,6.09-.38,1.52-.3,3.05-.31,4.58-.02,2.16-1.02,2.83-2.76,1.61-4.38-3.06-9.28-5.21-13.82-8.02-3.07-1.91-6.13-4-9.55-5.39-1.71-.7-3.13-2-4.7-2.98-2.04-1.28-4.19-2.36-6.3-3.44-2.99-1.54-5.52-3.81-8.62-5.14-1.47-.63-2.53-1.91-4.08-2.47-2.22-.81-4.12-2.14-5.92-3.7-1.18-1.02-2.85-1.31-4.25-2.1-2.16-1.22-4.14-2.8-6.51-3.61-.6-.2-1.03-.61-1.41-.92-2.76-2.19-6.15-3.27-8.99-5.23-3.02-2.08-6.29-3.69-9.34-5.68-.74-.48-1.47-.93-2.31-1.09-.66-.13-1.32-.36-1.77-.71-2.87-2.27-5.96-4.12-9.33-5.54-.55-.23-.97-.76-1.48-1.12-3.15-2.21-6.7-3.71-9.96-5.72-2.5-1.54-5.02-3.03-7.51-4.59-.72-.45-1.5-.69-2.3-.77-.64-.06-.9-.45-1.22-.85" width="70%" height="70%"/&amp;gt;
&amp;lt;/svg&amp;gt;
            &amp;lt;/mask&amp;gt;
        &amp;lt;/defs&amp;gt;
        &amp;lt;rect width="100%" height="100%" x="0" y="0" /&amp;gt;
 &amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;From the HTML code sample we have here, we are using the &lt;em&gt;&amp;lt; mask &amp;gt;&lt;/em&gt; tag to mask the SVG logo and the video under it.&lt;/p&gt;

&lt;p&gt;We also have a rect SVG shape that is masked together with the logo and shape.&lt;/p&gt;

&lt;p&gt;Now let’s create our CSS file and type the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @import url('https://fonts.googleapis.com/css2?family=Bowlby+One+SC&amp;amp;family=Koulen&amp;amp;family=Luckiest+Guy&amp;amp;display=swap');
    html {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    body {
        font-family: 'Bowlby One SC','Koulen','Luckiest Guy', cursive;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }

    video {
        width: 100%;
        height: 100%;
    }

  svg {
      font-size: 8em;
      font-family: "Koulen";
      transition: all 0.5s linear;
      position: absolute;
      inset: 0;
      height: 100%;
    }

    svg rect {
        fill: #fff;
        mask: url(#myText);
    }

    /* Media Query */
    @media screen and (max-width: 745px) {
        svg {
        font-size: 5em;
    }
    }
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/OJBGMMR?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A9ZK4B1hl083eLZdK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A9ZK4B1hl083eLZdK.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To show the SVG logo, the &lt;em&gt;&amp;lt; rect &amp;gt;&lt;/em&gt; shape is targeted and a fill of #fff (white is added) to display the logo.&lt;/p&gt;

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

&lt;p&gt;The SVG &lt;em&gt;&amp;lt; mask &amp;gt;&lt;/em&gt; Element has great support in all major browsers, so using it will bring the best result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A1g4DZV5DQTjaCZQC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A1g4DZV5DQTjaCZQC.png" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source- caniuse.com&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding CSS Transitions to CSS Masking Property
&lt;/h2&gt;

&lt;p&gt;Adding &lt;a href="https://www.lambdatest.com/blog/css-transforms-and-transitions-property/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS transitions&lt;/a&gt; to CSS masking property can help improve the look and feel of our website or application. It gives the user a sense of interactivity as they navigate the application, and it leads to good performance and optimization.&lt;/p&gt;

&lt;p&gt;In this section, let’s implement the properties we have learned till now by building simple card components with CSS masking and transiting them.&lt;/p&gt;

&lt;p&gt;Let’s begin.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main&amp;gt;
        &amp;lt;section class="container"&amp;gt;
            &amp;lt;!-- Card One --&amp;gt;
            &amp;lt;section class="card card-one"&amp;gt;
                &amp;lt;div class="image-wrapper"&amp;gt;
                    &amp;lt;img src="https://user-images.githubusercontent.com/78242022/246862734-89696683-7d0c-45af-b8d0-ddd9b59a986d.png" alt=""&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="content"&amp;gt;
                    &amp;lt;h3&amp;gt;Plugins &amp;amp; Extensions&amp;lt;/h3&amp;gt;
                    &amp;lt;p&amp;gt;Dedicated WordPress plugin and Chrome Extension to help you perform cross-browser testing and capture full-page
                    screenshots.&amp;lt;/p&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

        &amp;lt;!-- Card Two --&amp;gt;
        &amp;lt;section class="card card-two"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/246862738-773376b6-5b2d-411c-ba27-a96d92dc6150.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Test Locally hosted pages&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;Local hosted web testing to help you test in dev environments and save your website or app from after deployment bugs.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Card Three --&amp;gt;
        &amp;lt;section class="card card-three"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/246862710-a24aeea8-cce5-466e-b49f-903ac6b41bc1.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Geolocation testing&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;Test your website or mobile app from different geoIPs to make sure your users get the perfect experience across all
                locations.&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;!-- Card Four --&amp;gt;
        &amp;lt;section class="card card-three"&amp;gt;
            &amp;lt;div class="image-wrapper"&amp;gt;
                &amp;lt;img src="https://user-images.githubusercontent.com/78242022/246862742-4ee6ff1a-01ae-4766-bfe5-4910144d1db3.png" alt=""&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="content"&amp;gt;
                &amp;lt;h3&amp;gt;Accessibility Testing&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;Harness the power of Screen Reader and Speech Viewer using NVDA (Non-Visual Desktop Access) for Windows and Mac &amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;

        &amp;lt;/section&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Removing default white space */
        *,*::after, *::before {
            padding: inherit;
            margin: inherit;
            box-sizing: inherit;
        }

        html {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }


        /* Body */
        body {
            background-color: #d4d4d4;
            display: grid;
            place-items: center;
            width: 100vw;
            height: 100vh;
        }

        .container {
            display: grid;
            grid-template-columns: repeat(4, 300px);
            grid-template-rows: auto;
            gap: 1em;
        }

        .card {
            background-color: #0ebac5;
            border-radius: 10px;
            padding: 5px;
            box-shadow: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
        }

        .card:hover {
            outline-style: dashed;
            outline-width: 2px;
            outline-color: #242424;
        }

        .card:hover img {
            /* Chrome */
            -webkit-mask-image: linear-gradient(#000, transparent);
            -webkit-mask-size: 200px 200px;
            -webkit-mask-position: center center;

            /* Firefox */
            mask-image: linear-gradient(#000, transparent);
            mask-size: 200px 200px;
            mask-position: center center;

            transform: scale(1.1);
        }

        .content h3{
            font-family: calibri;
            font-size: 25px;
        }

        .content p{
            font-family: calibri;
            font-size: 20px;
            color: #242424;
        }

        /* hero images */
        .image-wrapper img{
            width: 100%;
            transition: all 0.5 ease-in;
            overflow: hidden;
            object-fit: cover;

            transition: all 0.5s ease;
        }


        /* Media Query */
        @media screen and (max-width: 1282px){
            .container {
            grid-template-columns: repeat(2, 300px);
        }
        }

        @media screen and (max-width: 700px){
            .container {
            grid-template-columns: repeat(1, 300px);
        }
        }
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/KKGYVBB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;From the browser preview, we added a linear gradient CSS masking to the hero image on the card components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding CSS Animations to CSS Masking Property
&lt;/h2&gt;

&lt;p&gt;CSS masking can be used to do many things, as you have seen from the previous section. One popular feature that is common among apps such as Instagram and TikTok is animating horizontal scroll text.&lt;/p&gt;

&lt;p&gt;This feature is very useful for long text that the user is not meant to scroll or interact with, the text can simply be animated so that all the information reveals itself and then repeats.&lt;/p&gt;

&lt;p&gt;Here is a similar example from TikTok for context.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aky32gNL3MAfLYgvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aky32gNL3MAfLYgvy.png" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the project demo of what we are going to create.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYd3iw7LGl21K50BK.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYd3iw7LGl21K50BK.gif" width="1366" height="730"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So let’s begin by creating an HTML file. Then type and run the code below&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main&amp;gt;
        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241960972-8df69d68-13b8-41a1-9a8f-610b32f1ba1d.png" alt="" class="lambdaTest"&amp;gt;
        &amp;lt;div class="box j"&amp;gt;
            &amp;lt;div class="k"&amp;gt;
                &amp;lt;p&amp;gt;LambdaTest - Next-Generation Mobile Apps and Cross Browser Testing Cloud&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;img src="https://user-images.githubusercontent.com/78242022/241950910-f15b21d2-d537-4a56-b7a6-99acd6ceb594.svg" alt="" class="music"&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; body {
            width: 100vw;
            height: 100vh;

            display: grid;
            place-items: center;

            overflow: hidden;
        }

        main {  
        width: 25em;
        height: 300px;
        background-color: #0ebac5;
        border-radius: 10px;
        box-shadow: 0 8px 10px -1px rgb(0 0 0 / 0.1), 0 8px 10px -2px rgb(0 0 0 / 0.1);
        border: 2px solid #fff;
        }

    .j{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .box {
        width: 100%;
        height: 50px;
        background-color: #0ebac5;
        -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent 100%);
        mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent 100%);

    }

    .k {
        -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent 100%);
        mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent 100%);
    }

    p {
        white-space: nowrap;

        font-size: 20px;
        font-family: calibri;
        font-style: italic;
        color: #fff;

        transform: translate(-500px);

        animation-name: moveforward;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
        animation-duration: 10s;
        animation-play-state: running;
    }

    /* Images Icons */
    .lambdaTest {
        display: block;
        margin: 1em auto;
        width: 150px;

        -webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, #000 60%, transparent 100%);
        mask-image: linear-gradient(180deg, transparent, #000 40%, #000 60%, transparent 100%);
    }

    .music {
        position: relative;
        bottom: 2em;
        margin-left: 10px;
    }

    @keyframes moveforward {
        0%{
            transform: translateX(0);
        }

        100%{
            transform: translateX(-500);
        }
    }
&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;iframe height="600" src="https://codepen.io/ocxigin/embed/yLRrYvb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2534%2F0%2ARQNLwLl_nql6XuSw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2534%2F0%2ARQNLwLl_nql6XuSw.png" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser preview, we have a simple plain text that animates to the left direction and then becomes hidden toward getting to the side mask bar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hide Text Content with CSS Masking
&lt;/h2&gt;

&lt;p&gt;In this section, we will learn how to hide text content with CSS masking. This feature is very effective for hiding a section of the page for the purpose of displaying exclusive content for a certain audience or limiting the amount of content a user has to interact with at a given time.&lt;/p&gt;

&lt;p&gt;First, let’s take a look at the final project demo.&lt;/p&gt;

&lt;p&gt;Now create an HTML file and type and run the code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main class="root"&amp;gt;
        &amp;lt;section class="hero-wrapper"&amp;gt;
            &amp;lt;section class="hero-section"&amp;gt;
                &amp;lt;!-- Call To Action --&amp;gt;
                &amp;lt;header class="call-to-action"&amp;gt;
                &amp;lt;div class="hero-space"&amp;gt;&amp;lt;/div&amp;gt;

                    &amp;lt;section&amp;gt;
                        &amp;lt;p&amp;gt;Free Live Webinar | Voices of Community&amp;lt;img src="https://raw.githubusercontent.com/ocxigin/we-love-ms/f786a998033224e244ce818ae6035ce4826df85a/img/icon-voices.svg"/&amp;gt;&amp;lt;/p&amp;gt;
                        &amp;lt;h1&amp;gt;Digital Accessibility Testing:  &amp;lt;br /&amp;gt;
                            How to Get It Right&amp;lt;/h1&amp;gt;
                        &amp;lt;p class="date"&amp;gt;
                            &amp;lt;img src="https://raw.githubusercontent.com/ocxigin/we-love-ms/f786a998033224e244ce818ae6035ce4826df85a/img/Date.svg"/&amp;gt;
                            &amp;lt;span&amp;gt;Wednesday, 31st May 2023&amp;lt;/span&amp;gt;
                        &amp;lt;/p&amp;gt;
                        &amp;lt;p class="time"&amp;gt;
                            &amp;lt;img src="https://raw.githubusercontent.com/ocxigin/we-love-ms/f786a998033224e244ce818ae6035ce4826df85a/img/bx_time.svg"/&amp;gt;
                            &amp;lt;span&amp;gt;8:30 - 9:30 PM IST | 11:00 - 12:00 PM EST&amp;lt;/span&amp;gt;
                        &amp;lt;/p&amp;gt;

                        &amp;lt;form action=""&amp;gt;
                            &amp;lt;button class="header-btn"
                                formaction="https://www.lambdatest.com/webinar/digital-accessibility-testing?utm_source=facebook&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_22&amp;amp;utm_term=sj&amp;amp;utm_content=webinar"&amp;gt;Register Now&amp;lt;/button&amp;gt;
                        &amp;lt;/form&amp;gt;
                    &amp;lt;/section&amp;gt;
                &amp;lt;/header&amp;gt;

                &amp;lt;!-- Call To Action --&amp;gt;
                &amp;lt;header class="speakers"&amp;gt;
                    &amp;lt;section&amp;gt;
                        &amp;lt;div class="hero-space"&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;!--This tag here is used for margin-top--&amp;gt;
                        &amp;lt;!-- Guest --&amp;gt;
                        &amp;lt;div class="guest"&amp;gt;
                            &amp;lt;div&amp;gt;
                                &amp;lt;img src="https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/tamar-schapira-profile.png" alt=""&amp;gt;
                            &amp;lt;/div&amp;gt;

                            &amp;lt;div class="names"&amp;gt;
                                &amp;lt;h1&amp;gt;Tamar Schapira&amp;lt;/h1&amp;gt;
                                &amp;lt;p&amp;gt;CEO/Co-Founder, &amp;lt;br /&amp;gt;
                                SenseIT&amp;lt;/p&amp;gt;
                            &amp;lt;/div&amp;gt;
                        &amp;lt;/div&amp;gt;

                        &amp;lt;!-- Host --&amp;gt;
                        &amp;lt;div class="host-top"&amp;gt;&amp;lt;/div&amp;gt;
                        &amp;lt;div class="host"&amp;gt;
                            &amp;lt;div&amp;gt;
                                &amp;lt;img src="https://raw.githubusercontent.com/ocxigin/we-love-ms/main/img/manoj-2023.png" alt=""&amp;gt;
                            &amp;lt;/div&amp;gt;

                            &amp;lt;div class="names"&amp;gt;
                                &amp;lt;h1&amp;gt;Manoj Kumar&amp;lt;/h1&amp;gt;
                                &amp;lt;p&amp;gt;VP - DevRel and OSPO, &amp;lt;br /&amp;gt;
                                    LambdaTest&amp;lt;/p&amp;gt;
                            &amp;lt;/div&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/section&amp;gt;
                &amp;lt;/header&amp;gt;
            &amp;lt;/section&amp;gt; &amp;lt;!--End of Hero Section--&amp;gt;

            &amp;lt;!-- Page Content --&amp;gt;
            &amp;lt;section class="content"&amp;gt;
                &amp;lt;section&amp;gt;
                    &amp;lt;div&amp;gt;
                        &amp;lt;h3&amp;gt;Abstract&amp;lt;/h3&amp;gt;
                        &amp;lt;div class="mask-text" id="maskText"&amp;gt;
                        &amp;lt;p&amp;gt;All people have the right and the ability to use the internet and participate in the digital world as they wish
                            and as
                            they are capable of. When speaking of users with disabilities, there are specific ways and functions by which
                            people use
                            digital products. Not all people were made equal and not all functions should be made equal. Digital
                            accessibility is
                            the inclusive practice that removes barriers for people with disabilities.&amp;lt;/p&amp;gt;

                        &amp;lt;p&amp;gt;As technology progresses and digital product development accelerates, digital accessibility is left behind and
                            generally
                       prioritized at the bottom of the list. This is primarily because assessing a product's accessibility is a manual
process. To overcome this problem, assessing for accessibility must be integrated early in development and
          continuously.
Meaning, we need to find a way to test and assess the product by interacting with the elements and components. Hence The usability test for accessibility needs to be automated.
                        &amp;lt;/p&amp;gt;

                        &amp;lt;p&amp;gt;In this session, Tamar Schapira, Co-Founder and CEO of Sense-IT will provide a proven automated methodology to
                            assess,
                            identify, and remediate accessibility violations for any web application.&amp;lt;/p&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/section&amp;gt;
            &amp;lt;/section&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;div class="btn-container"&amp;gt;
        &amp;lt;button class="btn" id="btn"&amp;gt;Toggle Mask&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- Fotter --&amp;gt;
    &amp;lt;footer class="footer"&amp;gt;
        &amp;lt;p&amp;gt;(c)2023 Alex Anie | All Rights Reserved&amp;lt;/p&amp;gt;
    &amp;lt;/footer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; *, *::after, *::before {
        padding: inherit;
        margin: inherit;
        box-sizing: inherit;
    }

    html {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .hero-space {
        margin-top: 4em;
    }

    .hero-section {
        /* background: linear-gradient(to top, transparent, #0e092c 50%); */
        background: #0e092c;
        width: 100vw;
        /* height: 100vh; */
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .call-to-action {
        margin-left: 1em;
    }

    .call-to-action h1 {
        font-family: calibri;
        font-size: 2.3em;
        color: white;
    }

    .call-to-action p:first-of-type {
        font-family: calibri;
        font-size: 1.5em;
        color: #298f95;
    }

    .date span, .time span{
        /* display: inline-block; */
        font-family: calibri;
        font-size: 1.2em;
        margin-left: 6px;
        position: relative;
        inset: -8px 0;
        color: white;
    }

    /* button */

    .header-btn, .btn {
        background-color: #45d7e8;
        padding: 1em 3em;
        border: none;
        border-radius: 5px;
        outline: none;
        font-weight: bold;
        margin-top: 2em;
        cursor: pointer;
        user-select: none;
    }

    .header-btn:hover {
        opacity: 0.8;
    }

    /* Speaker */
    .guest {
        display: flex;
        flex-direction: row;
    }

    .guest img {
        width: 117px;
        height: 128px;
    }

    .guest h1, .host h1 {
        font-family: calibri;
        font-size: 1.5em;
        color: white;
    }

    .guest p, .host p {
        font-family: calibri;
        font-size: 20px;
        color: white;
    }

    .host-top {
        margin-top: 1.4em;
    }

    .host {
        display: flex;
        flex-direction: row;
    }

    .host img {
        width: 117px;
        height: 127px;
    }

    .guest .names {
        position: relative;
        inset: 2em 3em;
    }

    .host .names {
        position: relative;
        inset: 2em 3em;
    }

    /* Content */
    .content {
        width: 50%;
        margin: 0 auto;
    }

    .content h3 {
        font-family: calibri;
        font-size: 1.2em;
        text-transform: uppercase;
        letter-spacing: 6px;
        margin: 2em 0;
    }

    .content p {
        font-family: calibri;
        font-size: 1.5em;
        margin: 1em 0;
        line-height: 1.5em;
    }

    /* footer */

    .btn-container {
        display: flex;
        justify-content: center;
    }
    .footer {
        background-color: #0e092c;
        width: 100%;
        height: 3em;
    }

    .footer p {
        text-align: center;
        color: white;
        font-family: calibri;
        font-style: italic;
        margin-top: 1em;
    }

    /* Mask Text */
    .mask-text {
        -webkit-mask-image: linear-gradient(to top, transparent, #000 100%);
        mask-image: linear-gradient(to top, transparent, #0e092c 50%);
    }

    /* Tablet */
    @media screen and (max-width:1057px){
        .hero-section {
        display: grid;
        grid-template-columns: repeat(1, 1fr);
    }

    .guest, .host {margin: 0 2em;}
    }


    /* Mobile */

    @media screen and (max-width:700px){
        .host, .guest {
        flex-direction: column;
    }

    .guest .names {
        inset: 10px 0;
        margin-bottom: 10px;
    }

    .host .names {
        inset: 10px 0;
        margin-bottom: 10px;
    }

    .content {
        width: 60%;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const btn = document.querySelector('#btn');
        const maskElement = document.querySelector('#maskText');

        btn.addEventListener('click', removeMask)

        function removeMask(){
            maskElement.classList.toggle('mask-text');
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The JavaScript code is added to enable the toggle function to the toggle mask button.&lt;/p&gt;

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

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ocxigin/embed/qBJwOvL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AivdBdukGfjAT5wPA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AivdBdukGfjAT5wPA.png" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser preview, CSS masking is applied to mask the content from displaying until a user clicks on the toggle mask button.&lt;/p&gt;

&lt;p&gt;We added a &lt;a href="https://www.lambdatest.com/blog/responsive-css-media-queries-for-responsive-design/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;media query &lt;/a&gt;breakpoint for a &lt;a href="https://www.lambdatest.com/learning-hub/responsive-design?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;responsive design&lt;/a&gt; so that the website will be responsive on different viewports and screen sizes.&lt;/p&gt;

&lt;p&gt;Here is a preview from various device screen sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Desktop Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ApQkdxLnR5aqJyxbj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ApQkdxLnR5aqJyxbj.png" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tablet Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ALtEZeORwDy-EPrqV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ALtEZeORwDy-EPrqV.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mobile Preview:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2At5MuBodYGl530zEM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2At5MuBodYGl530zEM.png" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above output has been rendered on &lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LT Browser 2.0 &lt;/a&gt;by the LambdaTest platform. It is a browser designed specifically for developers, offering a friendly environment for building, testing, and debugging mobile websites. It provides the capability to evaluate website performance across various mobile device viewports. Additionally, you have the flexibility to customize the viewport resolution for testing your websites and save these settings for future reference.&lt;/p&gt;

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

&lt;p&gt;With LT Browser 2.0, you can effortlessly explore and assess your websites on various screen resolutions, including desktops, mobile devices, tablets, and laptops. To begin using it, please refer to our &lt;a href="https://www.lambdatest.com/support/docs/lt-browser-2/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=support_doc" rel="noopener noreferrer"&gt;documentation on LT Browser 2.0.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Ensuring Accessibility with CSS Masking
&lt;/h2&gt;

&lt;p&gt;While performance deals with how fast a website performs, accessibility, on the other hand, deals with a website where all its features and content can be accessed irrespective of the physical impairments of the user.&lt;/p&gt;

&lt;p&gt;To ensure accessibility with CSS masking, proper use of Alpha Channel must be adhered to prevent CSS masking out content from visually impaired users. However, making good use of &lt;a href="https://www.lambdatest.com/blog/css-color-contrast/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;color contrast&lt;/a&gt; can be very helpful for color-blind users.&lt;/p&gt;

&lt;p&gt;Lastly, adhering to performance and accessibility best practices can help improve site performance when using CSS masking.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In this article, we will delve into the fundamentals of &lt;a href="https://www.lambdatest.com/learning-hub/quality-assurance?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Quality Assurance&lt;/a&gt;, its key principles, methodologies, and its vital role in delivering excellence.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With CSS masking, we can partially or fully hide parts of an element. This involves using graphical elements with an alpha channel, such as PNG images, SVGs, or Text.&lt;/p&gt;

&lt;p&gt;When in use, the specified element takes the shape of the object mask or linear gradient mask as an alpha or &lt;em&gt;luminance&lt;/em&gt; mask.&lt;/p&gt;

&lt;p&gt;Cheers! You’ve now learned the ins and outs of CSS masking. Armed with this knowledge, you can create visually stunning web designs that leave a lasting impression on your users. So go ahead, unleash your creativity, and push the boundaries of what’s possible with CSS masking!&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is CSS masking?
&lt;/h3&gt;

&lt;p&gt;CSS masking refers to a technique in Cascading Stylе Shееts (CSS) that allows you to apply a mask to an еlеmеnt’s contеnt, controlling its visibility or transparеncy. It enables you to crеatе visually intеrеsting еffеcts by hiding or rеvеaling parts of an еlеmеnt basеd on thе shapе dеfinеd by thе mask.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to mask an image in CSS?
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;mask-image&lt;/em&gt; CSS property sets the image used as a mask layer for an element. By default, this means the alpha channel of the mask image will be multiplied by the alpha channel of the element. This can be controlled with the mask-mode property.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>A Complete Guide to CSS Object Model (CSSOM)</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Thu, 16 Mar 2023 05:54:14 +0000</pubDate>
      <link>https://forem.com/testmuai/a-complete-guide-to-css-object-model-cssom-4k6m</link>
      <guid>https://forem.com/testmuai/a-complete-guide-to-css-object-model-cssom-4k6m</guid>
      <description>&lt;p&gt;If you are a front-end developer or a CSS enthusiast and you love writing code in CSS, words like Flexbox, Grid, Positioning, Box model, Selectors, Media Queries, Animations, Transforms and Transitions, and translate property, to mention a few, are not going to be strange to you, this is because these topics are talked about more and actively in every CSS community, forum and because you have personally used them.&lt;/p&gt;

&lt;p&gt;However, the CSS Object Model, also known as &lt;strong&gt;CSSOM&lt;/strong&gt;, is another significant CSS feature that is less well-known but even more crucial because it affects how the CSS we write daily renders on the browser.&lt;/p&gt;

&lt;p&gt;In this blog on CSS Object Model, we will be taking a closer look at what is CSS Object Model, how does CSS Object Model implement with browsers, and why it’s essential for a front-end developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is CSS Object Model (CSSOM)?
&lt;/h2&gt;

&lt;p&gt;CSSOM, also called CSS Object Model, is the set of web APIs that allows the manipulation of CSS from JavaScript with built-in instance properties and methods. Unlike the &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar16_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Document Object Model &lt;/a&gt;(DOM), which considers the page’s HTML document, the CSS Object Model works alongside the DOM and deals with the rendering of the stylesheet document.&lt;/p&gt;

&lt;p&gt;The stylesheet is linked and parsed to the browser through the HTML, where the CSS Object Model is combined with the DOM to form a render tree. This render tree contains the required nodes to render the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AgJpOmYTeEU_MjS8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AgJpOmYTeEU_MjS8r.png" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The rendering process of the CSS Object Model and the DOM is done within the browser and is called the &lt;strong&gt;critical rendering path&lt;/strong&gt;. It is the process or series of steps the browser goes through to convert the HTML, CSS, and JavaScript into pixels that display on the screen. This path comprises CSS Object Model, DOM, layout, and rendering tree, as shown in the figure below.&lt;/p&gt;

&lt;p&gt;Here are the steps in the critical rendering path:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Development of DOM, CSS Object Model, and execution of JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The browser loads the HTML file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Request the JavaScript and CSS files via the &amp;lt; script &amp;gt; and &amp;lt; link &amp;gt; tags, respectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript, through the DOM, makes the necessary changes and updates the document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Layout computes the exact position and size of each object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CSS is then parsed as the CSS Object Model build and changes the style in the DOM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Paint translates into actual pixels and displays them on the screen.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AtZ5RB4S7M6Y_Ef0F.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AtZ5RB4S7M6Y_Ef0F.png" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The browser engine translates this process and creates the render tree. As soon as the layout and how each element is to be positioned have been determined, pixels are painted out by the browser to the screen.&lt;/p&gt;

&lt;p&gt;It’s also important to consider that whether or not we add style rules to the webpage, the browser, by default, assigns in-built styles to the document loaded on the browser; this is called user-agent or user-agent-stylesheet.&lt;/p&gt;

&lt;p&gt;However, frontend developers or web designers create their external style sheet called author style-sheet; this CSS style is linked to the HTML file. This is the most common style sheet as developers write them to correct and update the user-agent-stylesheet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get started with this complete &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar14_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; automation testing tutorial. Learn what Selenium is, its architecture, advantages and more for automated cross browser testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Styling DOM Elements with CSS Object Model
&lt;/h2&gt;

&lt;p&gt;In this section, we will look at a few JavaScrit properties and methods that can be used to style the DOM with CSS Object Model directly from JavaScript.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;User-Agent-Stylesheet/Author Stylesheet&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before we dive deep into properties and methods for manipulating the DOM with CSS Object Model, let’s see how the &lt;strong&gt;user-agent-stylesheet&lt;/strong&gt; and &lt;strong&gt;author stylesheet&lt;/strong&gt; interact with the document loaded on the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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;
        This is a CSS style Example
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the above HTML code example, we created a &amp;lt; div &amp;gt; tag with text content. Now let’s add some styling to it.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; div {
        width: 200px;
        height: 200px;
        background-color: purple;
        color: white;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We have created a &amp;lt; div &amp;gt; tag with properties, i.e., width and height of 200px, background color purple, and color for the text is kept white.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2AcJblGbi9QODW19q3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2AcJblGbi9QODW19q3.png" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, we have a &amp;lt; div &amp;gt; tag displayed as a square, with a background color of purple (color code: #A020F0). Before we apply CSS styles, let’s see how the user-agent affects the element we created and how we can overwrite each property with the author style-rule.&lt;/p&gt;

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

&lt;p&gt;The output image is taken from LambdaTest’s platform while performing &lt;a href="https://www.lambdatest.com/live-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;real-time testing&lt;/a&gt;. LambdaTest is a cloud-based &lt;a href="https://www.lambdatest.com/cross-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platform that allows you to test your web and mobile applications over more than 3000+ browsers and device configurations. It also supports &lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing&lt;/a&gt; to perform multiple tests in the same environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2534%2F0%2A6nKvUfa_K67j-E43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2534%2F0%2A6nKvUfa_K67j-E43.png" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a better understanding of how this works, here are the steps you need to follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Launch your DevTools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the element and select computed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the div on the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As indicated by the arrow on the right, see the user agent style-sheet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, from the yellow box, the user-agent sets the &amp;lt; div &amp;gt; to display block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;font-family of Times New Roman and font size of 16px&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As mentioned earlier, the user-agent is responsible for setting default values to elements properties when loaded on the browser if the author style rule is not declared for that specific property.&lt;/p&gt;

&lt;p&gt;Now let’s see how we can overwrite the user agent-stylesheet using the author stylesheet we created in our CSS.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; div {
        width: 200px;
        height: 200px;
        background-color: purple;
        color: white;
        font-family:monospace;
        font-size: 32px;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the CSS code sample above, we targeted the &lt;em&gt;font-family&lt;/em&gt; and &lt;em&gt;font-size&lt;/em&gt; property, and we set them to monospace and 32px respectively.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2Aj8UKdcgjPvStdT5O.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2Aj8UKdcgjPvStdT5O.png" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, the &lt;em&gt;font-size&lt;/em&gt; is now much bigger than the one we had before, and the &lt;em&gt;font-family&lt;/em&gt; is now monospace. Let’s see how this has affected the user-agent-stylesheet with the DevTools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AFx4vqGqj3ClMtCoF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AFx4vqGqj3ClMtCoF.png" width="800" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we just had one user-agent stylesheet rule, which is &lt;em&gt;display block&lt;/em&gt;. The font-size of 16px and the &lt;em&gt;font-family&lt;/em&gt; of Times New Roman had been overwritten.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Inline style property&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we have seen how the user-agent and author-stylesheet work, let’s see how to manipulate the DOM with CSS Object Model with the style property.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;HTMLElement.style&lt;/em&gt; property specifies the inline style of an Element. This is a read-only property that returns &lt;em&gt;CSSSyleDeclaration&lt;/em&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Assigning the div element to a div variable
  const div = document.querySelector('div');

// Using the style property to manipulate the div element
  div.style.backgroundColor = 'orange';
  div.style.border = '5px solid red';
  div.style.borderRadius = '5px';
  div.style.paddingTop = '10px';
  div.style.paddingLeft = '10px';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code example above, we assign a &amp;lt; div &amp;gt; tag to a div variable we created, and we apply a backgroundColor of orange ( #FFA500), a border of 5px solid, and a color of red, paddingTop and paddingLeft 10px across respectively.&lt;/p&gt;

&lt;p&gt;When working with the style properties, it’s important to note that the CSS Reference property, a list of CSS properties accessible by the style property, is all in camelCase. For example, the background-color is written as backgroundColor with the (-) hyphen omitted.&lt;/p&gt;

&lt;p&gt;This is because the (-) hyphen is an &lt;em&gt;Arithmetic Operator&lt;/em&gt; for subtraction, so putting the hyphen (-) in between the background and color will throw an error. However, shorthand property does not require a hyphen (-), a perfect example of this border property we defined earlier.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2A8fXuy5aCs_yMJM3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2A8fXuy5aCs_yMJM3n.png" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have successfully changed the element styles using the style property, the style property, as mentioned earlier, returns the inline style. Any style we set using the style property appears aligned with the element. Let’s check our DevTools to see how this works.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A5sXkjLAi6ek6tbHw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A5sXkjLAi6ek6tbHw.png" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As seen from the DevTools output, each property is parsed inside the element as a value to the style property. While the style property can be beneficial, it can also cluster your HTML and JavaScript.&lt;/p&gt;

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

&lt;p&gt;The &lt;em&gt;window.getComputedStyle()&lt;/em&gt; returns the values of an object of all the CSS properties of an element; this can either be the element values or pseudo-element values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Get Element Value with GetComputedStyles&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, we will see how to return an element value with the GetComputedStyle method.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.getComputedStyle(element)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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;
   The example here is about window.getComputedStyle(element)
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div {
        width: 500px;
        height: 200px;
        background-color: purple;
        color: white;
        font-family:monospace;
        font-size: 20px;
        padding: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the CSS code example above, we targeted the div tag and set the width to 500px, height to 200px, &lt;em&gt;background-color&lt;/em&gt; to purple, color to white, &lt;em&gt;font-family&lt;/em&gt; to monospace, &lt;em&gt;font-size&lt;/em&gt; to 20px and padding to 20px across.&lt;/p&gt;

&lt;p&gt;Now let’s see how we can access and return this value using JavaScript’s &lt;em&gt;getComputedStyle()&lt;/em&gt; method.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const div = document.querySelector('div');

const getProValue = window.getComputedStyle(div);

div.innerHTML = `We are using the getComputedStyle method to return the font-family which is: ${getProValue.fontFamily} and the font-size which is: ${getProValue.fontSize}`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the JavaScript code example above, we used the &lt;em&gt;getComputedStyle()&lt;/em&gt; method to return the value of the &lt;em&gt;font-family&lt;/em&gt; and &lt;em&gt;font-size&lt;/em&gt; of the specified element.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2594%2F0%2A5kQyD1nboCUcYYO7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2594%2F0%2A5kQyD1nboCUcYYO7.png" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As seen from the browser output, we have the &lt;em&gt;font-family&lt;/em&gt; value monospace and the &lt;em&gt;font-size&lt;/em&gt; value 20px printed out.&lt;/p&gt;

&lt;p&gt;Unlike the style property we explained earlier, the &lt;em&gt;getComputedStyle()&lt;/em&gt; method does not set a value to an element. It returns a value set to that element and other associated properties, even if the value still needs to be specified.&lt;/p&gt;

&lt;p&gt;Let’s take another approach and return all the values associated with the &amp;lt; div &amp;gt; element using the &lt;em&gt;getComputedStyle()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;Type the following command and hit enter on the browser console.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.getComputedStyle(div)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A0eGX8hSquiocQY3i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A0eGX8hSquiocQY3i.png" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Through this &lt;a href="https://www.lambdatest.com/learning-hub/usability-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar14_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;usability testing&lt;/a&gt; tutorial, you will learn how usability testing is a great way to discover unexpected bugs, find what is unnecessary or unused before going any further, and have unbiased opinions from an outsider.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The property is returned as a CSSSyleDeclaration object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Get Pseudo-Element with GetComputedStyles&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this section, we will see how to return a Pseudo-Element with the &lt;em&gt;GetComputedStyle()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;To do this, we have to assign the pseudo-element &lt;em&gt;::before&lt;/em&gt; or &lt;em&gt;::after&lt;/em&gt; as an argument to the &lt;em&gt;GetComputedStyle()&lt;/em&gt; method to a specified element.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.getComputedStyle(element, pseudo-element)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;Return background Pseudo-element&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p::after {
    content: "";
    background: purple;

    display: block;
     width: 400px;
     height: 100px;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the CSS code example above, we created a Pseudo-Element after the paragraph’s content. We set the content to an empty string because we don’t want any content in the Pseudo-Element; the background is set to purple.&lt;/p&gt;

&lt;p&gt;Then we set the display to block to bring the Pseudo-Element to a new line, a width of 400px and a height of 100px, respectively.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const para = document.querySelector("p");
const printBG = getComputedStyle(para, "::after").background;

console.log("print the RGB value of background: ", printBG);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We targeted the background color of the Pseudo Element of the paragraph tag, and we are getting the background value set on the Pseudo-Element.&lt;/p&gt;

&lt;p&gt;Now let’s see how this looks on the browser.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AHepVokslNoPWQPVr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AHepVokslNoPWQPVr.png" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, the RGB value of purple is printed out.&lt;/p&gt;

&lt;p&gt;Check out the top 18 &lt;a href="https://www.lambdatest.com/blog/advanced-css-tricks-and-techniques/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;advanced CSS tricks and techniques&lt;/a&gt; you should know in 2023 to help you master &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=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;modern web design&lt;/a&gt; and development skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSSStyleDeclaration Interface
&lt;/h2&gt;

&lt;p&gt;In this section, we will see how we can use the CSSStyleDeclaration Interface, its properties, and the methods used in the CSS Object Model.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;getPropertyValue()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;getPropertyValue()&lt;/em&gt; method interface is used to return a string value of CSSStyleDeclaration of a given value of an element. The &lt;em&gt;getPropertyValue()&lt;/em&gt; takes a property name string as an argument and returns the property value.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getPropertyValue(property)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main&amp;gt;
        &amp;lt;p&amp;gt;Return background Pseudo-element&amp;lt;/p&amp;gt;
 &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p{
    background: purple;
    color: white;

    width: 400px;
    height: 100px;

    font-family: monospace;
    font-size: 20px;
    padding: 10px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code example above, we targeted the &amp;lt; p &amp;gt; tag and applied a background of purple, the color of white, a width of &lt;em&gt;400px&lt;/em&gt;, the height of &lt;em&gt;100px&lt;/em&gt;, &lt;em&gt;font-family&lt;/em&gt; of monospace, font-size of &lt;em&gt;20px&lt;/em&gt; and padding of &lt;em&gt;10px&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now let’s see how we can use JavaScript to return the width and height value of the paragraph element.&lt;/p&gt;

&lt;p&gt;Try the code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Assigning the p element to a variable
const par = document.querySelector('p');

// Here we return the CSS properties by getting the
// computed styles.
const getProValue = window.getComputedStyle(par);

// Here we are returning the value of width and height to the innerHTML
par.innerHTML = `The the width of the paragraph is: ${getProValue.getPropertyValue('width')} and the height is: ${getProValue.getPropertyValue('height')}`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the JavaScript example, our code has three phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first phase is when we assign the &amp;lt; p &amp;gt; tag to a variable par&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second phase is when we get the properties of &amp;lt; p &amp;gt; tag and assign it to the getProValue variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The third phase is when we parse the variable value to the inner HTML and return the width and height properties assigned to the elements using the &lt;em&gt;getPropertyValue()&lt;/em&gt; method.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let’s see how this runs on the browser.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2At-pYSPobAF2x7b7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2At-pYSPobAF2x7b7m.png" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The width and height are printed from the browser output on the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/system-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar14_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;System testing&lt;/a&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;ul&gt;
&lt;li&gt;&lt;strong&gt;getPropertyPriority()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The getPropertyPriority() method interface of the CSSStyleDeclaration object is used to check the priority of a specified property of a given element.&lt;/p&gt;

&lt;p&gt;If the critical keyword is present, it returns important; if not, it returns an empty string.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getPropertyPriority('background') 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the code example below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="first-case"&amp;gt;
        &amp;lt;p class="present p" style="background: purple !important;"&amp;gt;This element has "important" property&amp;lt;/p&amp;gt;
        &amp;lt;p class="not-present p"&amp;gt;This element does NOT has "important" property&amp;lt;/p&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the HTML code example above, we created a &amp;lt; main &amp;gt; tag with a class of first-case and inside this tag, we nested two &amp;lt; p &amp;gt; tags, with a class of p for both tags and present and not-present for each respectively.&lt;/p&gt;

&lt;p&gt;The present, as seen, is explicitly defined with a style property and a value of background purple and then the important keyword.&lt;/p&gt;

&lt;p&gt;The not-present, on the other hand, is left without a style property.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.first-case{
    display: flex;
}

.p{
    background: purple;
    color: white;

    width: 400px;
    height: 100px;

    font-family: monospace;
    font-size: 20px;
    padding: 10px;
    margin-right: 20px;
}

.not-present {
    background: orange;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the CSS code example above, we targeted the parent tag, &amp;lt; main &amp;gt; with a class of first-case and we set it to display: flex, making the children element &amp;lt; p &amp;gt; to sit side by side because they are now flex items.&lt;/p&gt;

&lt;p&gt;Then we use the p class, which both &amp;lt; p &amp;gt; tags have in common, and we set it to a background of purple, the color of white, a width of &lt;em&gt;400px&lt;/em&gt;, and a height of &lt;em&gt;100px&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Also, the font-family is set to monospace, and the font-size is set to &lt;em&gt;20px&lt;/em&gt; to make it bold for readability purposes. At the same time, the padding and margin-right take &lt;em&gt;10px&lt;/em&gt; and &lt;em&gt;20px&lt;/em&gt;, respectively.&lt;/p&gt;

&lt;p&gt;Now let’s see how we can access this using JavaScript below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Section ONE
    const par1 = document.querySelector('.present');
    const par2 = document.querySelector('.not-present');

    // Section TWO
    const proOne = par1.style.getPropertyPriority('background');
    const proTwo = par2.style.getPropertyPriority('background');

    // Section THREE
    const returnOne =  par1.innerHTML = `The background of the paragraph is: ${proOne}`;
    const returnTwo =  par2.innerHTML = `The the background of the paragraph is: ${proTwo}`;

    console.log(returnOne)
    console.log(returnTwo)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Our JavaScript code above is divided into three sections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First, we apply the two &amp;lt; p &amp;gt; to two different variables par1 and par2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, use the style property to return the background property, and the &lt;em&gt;getPropertyPriority()&lt;/em&gt; method is used to check if the property being returned is specified with the important keyword.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lastly, we use the innerHTML to print out the value to the screen.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Also, we return the value to the console for the case of clarity.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AoD5kDz2WOeagF5i-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AoD5kDz2WOeagF5i-.png" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;As seen from the browser preview and console, the important keyword is printed in the first tag while an empty string is returned.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;setProperty()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;setProperty()&lt;/em&gt; method interface of the CSSStyleDeclaration object is used to set a new value to the style property of a given element. The setProperty method takes in two or three arguments. The last argument (i.e., priority) is optional.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setProperty(propertyName, value)
setProperty(propertyName, value, priority)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Property name can be added in a single or double quote and then its value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second syntax is an important keyword in that double or single quote.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="first-case"&amp;gt;
        &amp;lt;p class="p one"&amp;gt;This element does NOT have "important" property&amp;lt;/p&amp;gt;
        &amp;lt;p class="p two"&amp;gt;This element has "important" property&amp;lt;/p&amp;gt;
 &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Just like the previous code example, the HTML code above has two &amp;lt; p &amp;gt;, what we are going to do is set the style property with a background-color of green and brown to both tags and apply the important keyword to the lask &amp;lt; p &amp;gt; tag.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.first-case{
    display: flex;
}

.p{
    color: white;

    width: 400px;
    height: 100px;

    font-family: monospace;
    font-size: 20px;
    padding: 10px;
    margin-right: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the CSS code above, the parent element &amp;lt; main &amp;gt; tag with a class of first-case is set to display: flex, while the two &amp;lt; p &amp;gt; paragraph tags take a width and height of &lt;em&gt;400px&lt;/em&gt; and &lt;em&gt;100px&lt;/em&gt; respectively. Color of white, font-family of monospace, font-size of &lt;em&gt;20px&lt;/em&gt;, padding of 10px, and margin-right of &lt;em&gt;20px&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now try the JavaScript code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Section ONE
    const par1 = document.querySelector('.one');
    const par2 = document.querySelector('.two');

    // Section TWO
    const proOne = par1.style.setProperty('background', 'green');
    const proTwo = par2.style.setProperty('background', 'brown', 'important');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This section has two parts of the JavaScript code above that explain what we are trying to do. We apply a background of green to the first tag and a background of brown to the section with the important value.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2546%2F0%2AgU4L439GW9vVOgir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2546%2F0%2AgU4L439GW9vVOgir.png" width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive User &lt;a href="https://www.lambdatest.com/learning-hub/user-acceptance-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar14_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Acceptance Testing&lt;/a&gt; (UAT) tutorial that covers what User Acceptance Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While observing the browser output, launch your DevTools and check the element tag; observe how the style tag is now inserted into both elements as indicated by the arrow and compare it with the HTML code we wrote.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;removeProperty()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;removeProperty()&lt;/em&gt; method interface of the CSSStyleDeclaration object is used to remove a style property from a given element. The removeProperty method takes in the CSS style property to be removed as an argument.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;removeProperty(property)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="p one" style="background: purple;"&amp;gt;This element does NOT have a background color&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, we make use of the same HTML element from the previous example.&lt;/p&gt;

&lt;p&gt;Now let’s type out the CSS code.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.p{
    color: black;

    width: 400px;
    height: 100px;

    font-family: monospace;
    font-size: 20px;
    padding: 10px;
    margin-right: 20px;

    border: 5px solid black;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this section, we also make use of the same code from the previous section with some little modification. We changed the color from white to black, then added a &lt;em&gt;border&lt;/em&gt; of 5px solid with the color &lt;em&gt;black&lt;/em&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Section ONE
    const par1 = document.querySelector('.one');

 // Section TWO
 const proOne = par1.style.removeProperty('background');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We used the &lt;em&gt;removeProperty()&lt;/em&gt; method to remove the background poverty from the &amp;lt; p &amp;gt; element. From the browser output, you will see that the box does not have a background color.&lt;/p&gt;

&lt;p&gt;It’s important to note that when using multi-line words like background-color, use a hyphen and place it inside a single or double quote.&lt;/p&gt;

&lt;p&gt;See the browser output below.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F0%2AMulZJ0jUHQguKycy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F0%2AMulZJ0jUHQguKycy.png" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/ad-hoc-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar14_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Ad hoc testing&lt;/a&gt; tutorial, let’s deep dive into what Ad hoc testing is, its advantages, disadvantages, types, characteristics, and their best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The browser output shows that the style attribute is still present, but the background property and value are completely removed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;item()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The item() method interface of the CSSStyleDeclaration object returns a style property from a given element. The item() method uses a positive integer as an argument and returns the property at the index.&lt;/p&gt;

&lt;p&gt;If the item() method will return a space if you do the following;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pass in a negative integer, for example, -1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the integer passed is greater than the length of the properties of the specified element,&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if the item() is left empty without no value passed, it returns as Uncaught TypeError.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;item(index)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Working with the item() method can be very confusing if you are trying it for the first time, so to make it easy, we are going to use two example methods to explain how the item() method works.&lt;/p&gt;

&lt;p&gt;In the first example, we will use Longhand properties with the style attribute, while in the second example, we will use the Longhand and Shorthand properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using item() to access longhand properties&lt;/strong&gt;&lt;br&gt;
In this section, we will use the longhand property within the style attribute and then use the item() method to return the given property at a specified index.&lt;/p&gt;

&lt;p&gt;Try the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&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="p one" style="color: white;
                        background-color: purple;
                        font-family: monospace;
                        width: 400px;
        "&amp;gt;
       This element has four items but its index at 0
       &amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the HTML code above, we have four properties assigned to the style attribute which are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;color&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;background-color&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;font-family and&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;width&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are going to be returning this property with the item() method.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.p{
    width: 400px;
    height: 100px;

    font-size: 20px;
    padding: 10px;
    margin-right: 20px;
    border: 5px solid black;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We added the following CSS styles to the &amp;lt; p &amp;gt; tag, which is a width and height of 400px and 100px, font-size of 20px, a padding of 20px and border of 5px solid and color of black.&lt;/p&gt;

&lt;p&gt;Many web developers forget font typography and spacing in &lt;a href="https://www.lambdatest.com/blog/css-forms/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS styling&lt;/a&gt;. Typography and font spacing in CSS is important for creating a visually appealing and easy-to-read website. To know in detail, please check our blog on &lt;a href="https://www.lambdatest.com/blog/css-font-spacing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS Font Spacing&lt;/a&gt; will cover everything you need to know about typography and font spacing in CSS and the different ways of achieving that.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Section ONE
    const par1 = document.querySelector('.one');

    // Section TWO
    const proOne = par1.style.item(0);
    const proTwo = par1.style.item(5);
    const proThree = par1.style.item(3);

    // Section THREE
    console.log(proOne);
    console.log(proTwo);
    console.log(proThree);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The JavaScript code is ground into three sections.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;One, we assigned the &amp;lt; p &amp;gt; to a variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Two, we passed in three item() to three different variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Three, we printed out each value to the console.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the browser output below.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2ApVGIR-tK_H2WVt9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2ApVGIR-tK_H2WVt9v.png" width="800" height="433"&gt;&lt;/a&gt;&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;a href="https://www.lambdatest.com/blog/test-internet-explorer-for-mac/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Internet Explorer on Mac&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, the color and width returned properties have a huge space in between. This is the return value of the second variable we logged to the console.&lt;/p&gt;

&lt;p&gt;The second variable takes in an argument of 5 integers, which is longer than the maximum length value of the specified element.&lt;/p&gt;

&lt;p&gt;To get the length of all properties in the element, type the following on the console.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;par1.style.length 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This should return the length value.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AeyBVpOcfkJMAUVZM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AeyBVpOcfkJMAUVZM.png" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The length of the properties passed to the style attribute is 4, as seen from the console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using item() to access shorthand properties&lt;/strong&gt;&lt;br&gt;
Now that we have seen how longhand works, let’s add two shorthand properties and remove two longhand properties from the style attribute.&lt;/p&gt;

&lt;p&gt;Try the code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="first-case"&amp;gt;
        &amp;lt;p class="p one" style="color: white;
                                background: purple;
                                font-family: monospace;
                                border: 5px solid black;
        "&amp;gt;
       This element has four items but its index at 0
       &amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the HTML code above, we replace just two colors as follows;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Background-color longhand property to background shorthand&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;width to border&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While the remaining two remain the same.&lt;/p&gt;

&lt;p&gt;Try the JavaScript code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Section ONE
    const par1 = document.querySelector('.one');

    // Section TWO
    const proOne = par1.style.item(0);
    const proTwo = par1.style.item(5);
    const proThree = par1.style.item(3);

    // Section THREE
    console.log(proOne);
    console.log(proTwo);
    console.log(proThree);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Type and run the JavaScript code above.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2A0dYB196OGqcZzAWF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2A0dYB196OGqcZzAWF.png" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, we have color background-repeat-x, and background-position-y printed on the console.&lt;/p&gt;

&lt;p&gt;The HTML file has the same number of properties just like the first one; the only difference is that we have two shorthand properties. So the item() fetches and returns every other property associated with the shorthand properties we assigned to the style attribute whether or not we explicitly specified it.&lt;/p&gt;

&lt;p&gt;To see how this was done, let’s access the length.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;par1.style.length
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This should return the length value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2ApwcRReFr9vXaClip.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2ApwcRReFr9vXaClip.png" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Upload your app for testing within seconds using the LambdaTest cloud and perform &lt;a href="https://www.lambdatest.com/mobile-app-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile app test&lt;/a&gt; right away. Find bugs early on, improve performance, quality, user experience and make the most of mobile application testing on LambdaTest.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, 29 is printed out, as seen from the console.&lt;/p&gt;

&lt;p&gt;To check all the properties being returned. Type and run the code below on the console.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;par1.style
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This should return all the properties associated with the element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2A1If3i1LtlYUixjAD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2A1If3i1LtlYUixjAD.png" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s essential to remember that the length is 28, and its index is 0, making it 29.&lt;/p&gt;

&lt;h2&gt;
  
  
  StyleSheet interface
&lt;/h2&gt;

&lt;p&gt;Now, in this section, we’ll discuss another style interface that comes under CSS Object Model, i.e., the Stylesheet interface presents an object, a single stylesheet within the HTML document.&lt;/p&gt;

&lt;p&gt;See the illustration for a better understanding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AF2ZuBXjiB6S8tc0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AF2ZuBXjiB6S8tc0z.png" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Properties:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To put it in simple terms, the instance properties of the stylesheet interface represent the attributes within the HTML &amp;lt; link &amp;gt; tag, including the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;disabled:&lt;/strong&gt; this is a boolean value that determines whether the stylesheet is prevented from applying to the document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;href:&lt;/strong&gt; use to return the location of the stylesheet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;media:&lt;/strong&gt; used to set or specify the media the stylesheet is made for, E.g, screen/print.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ownerNode:&lt;/strong&gt; return the node connecting the stylesheet to the document. E.g., the &amp;lt; link &amp;gt; tag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;parentStyleSheet:&lt;/strong&gt; return the current stylesheet if present or &lt;em&gt;null&lt;/em&gt; if not present.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;title:&lt;/strong&gt; returns the advisory title of the current stylesheet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;type:&lt;/strong&gt; return a string specifying the style language of the stylesheet.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  StyleSheetList
&lt;/h2&gt;

&lt;p&gt;This is another important style in the CSS Object Model, i.e., the &lt;em&gt;StyleSheetList&lt;/em&gt; interface that returns a collection of &lt;em&gt;CSSStyleSheet objects&lt;/em&gt; and behaves like an array-like object. It can be accessed using length property and item() methods.&lt;/p&gt;

&lt;p&gt;Consider the illustration below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AR4VJvlD7olOwtXvL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AR4VJvlD7olOwtXvL.png" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before we write any code, let’s see exactly how &lt;em&gt;StyleSheetList&lt;/em&gt; works in the CSS object model.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;length (Instance Property)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The length instance property of the StyleSheetList object returns the total length of the stylesheet object present in the document. For example, when we link a stylesheet to our HTML document using the HTML &amp;lt; link &amp;gt; tag, we have added one stylesheet object to that document which will be returned by the length instance property anytime we try to access it.&lt;/p&gt;

&lt;p&gt;However, if we use the internal style tag &amp;lt; style &amp;gt; instead, we have added a stylesheet object. So the number of &amp;lt; link &amp;gt; we add determines the number that will be returned by the length property when we choose to use it.&lt;/p&gt;

&lt;p&gt;Also, remember that using the &lt;a href="http://twitter.com/import" rel="noopener noreferrer"&gt;@import&lt;/a&gt; CSS keyword to import an external file through the CSS file, the length property will not return it, as its only return using the &amp;lt; link &amp;gt; tag and internal &amp;lt; style &amp;gt; tag.&lt;/p&gt;

&lt;p&gt;And if there happens to be no tag, that is &amp;lt; link &amp;gt; and &amp;lt; style &amp;gt; tag. The length property returns 0 integers.&lt;/p&gt;

&lt;p&gt;Consider the code example below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;CSSOM EXAMPLES&amp;lt;/title&amp;gt;

    &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
    &amp;lt;link rel="stylesheet" href="import.css" title="a title" media="screen" type="text/css"&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;style&amp;gt;
    /*
  PLEASE NOT THIS WAS INTENTIONAL
  This internal style tag was keep like this on purpose
*/
&amp;lt;/style&amp;gt;

&amp;lt;body&amp;gt;
...
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the HTML code example above, we added three &amp;lt; link &amp;gt; tags and one &amp;lt; style &amp;gt; tag. Making it four stylesheet objects we have added to the document.&lt;/p&gt;

&lt;p&gt;Now let’s see if the length property will return the stylesheet number of 4 as expected.&lt;/p&gt;

&lt;p&gt;Consider the JavaScript code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stylesheet = document.styleSheets.length;
 console.log(stylesheet);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The JavaScript code seems very basic here. We use the length property to return the number of stylesheet objects in the document.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A8ZYmJ0g8CnNockz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A8ZYmJ0g8CnNockz6.png" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As seen from the console. The number 4 integer is logged out.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;item() (Instance Method)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The item() instance method of the StyleSheetList object returns a single stylesheet item from the total length of the stylesheet object present in the document.&lt;/p&gt;

&lt;p&gt;For example, all you have to do is pass in a positive integer as an argument, and the item() returns the exact stylesheet based on the index provided.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;item(index)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It’s important to note that the item() method is indexed at 0 integers. So index three will log out the fourth item.&lt;/p&gt;

&lt;p&gt;Consider the JavaScript code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stylesheet = document.styleSheets;
console.log(stylesheet. item(3));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ABeBG3RLgGolFW-5O.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ABeBG3RLgGolFW-5O.png" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have successfully logged the fourth item of the CSSStylesheet object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Passing StyleSheet Object to a new Array&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using array methods will throw an error, but we can use a for loop to convert it into an array and loop through them.&lt;/p&gt;

&lt;p&gt;Now let’s see some examples below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stylesheet = document.styleSheets;

let newArr = [];

for(let i = 0; i &amp;lt; stylesheet.length; i++){
    let output = newArr.push(stylesheet[i]);

    console.log(output)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code, what we are doing is using a for loop to loop over each item of the stylesheet object and then assign it to a new array called newArr.&lt;/p&gt;

&lt;p&gt;Then we store the value in an output variable logged into the browser console.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AKR9O6MIeYuxoNDB5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AKR9O6MIeYuxoNDB5.png" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As seen from the console. The four stylesheet objects are printed out.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSSStyleSheet
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;CSSStyleSheet&lt;/em&gt; interface lets you inspect, return or modify CSS properties and values within the stylesheet objects. This behaves like an array-like object and can be accessed through the length property and the CSSStyleSheet instance methods under CSS Object Model properties.&lt;/p&gt;

&lt;p&gt;Consider the illustration below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A6x3jDnQ_SzY9yuSh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A6x3jDnQ_SzY9yuSh.png" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The stylesheet object contains a collection of CSS properties and values in a code block for context.&lt;/p&gt;

&lt;p&gt;Consider the code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main {

    width: 400px;
    height: 100px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above CSS code is one code block, which is a &lt;em&gt;cssRule&lt;/em&gt;. A code block in CSS is a collection of properties and values wrapped inside open and closed &lt;em&gt;curly braces&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This code block is what is referred to as a &lt;em&gt;cssRule&lt;/em&gt;. When we have two or more cssRule, it is called a &lt;em&gt;cssRuleList&lt;/em&gt;, a list of &lt;em&gt;cssRule&lt;/em&gt;. The &lt;em&gt;cssRuleList&lt;/em&gt; can be accessed via the &lt;em&gt;cssRules&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;&lt;a class="mentioned-user" href="https://dev.to/import"&gt;@import&lt;/a&gt;&lt;/em&gt; and &lt;em&gt;&lt;a class="mentioned-user" href="https://dev.to/media"&gt;@media&lt;/a&gt;&lt;/em&gt; are also part of the cssRuleList.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Properties&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The cssRules of the CSSStyleSheet interface lets you return a live cssRuleList within the stylesheet object. This is a real-time update of the cssRuleList.&lt;/p&gt;

&lt;p&gt;Try and run the code below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
main {

    width: 400px;
    height: 100px;
}

.p{
    background: purple;
    color: white;  
}

.one {
    float: right;
}

.two {
    background-color: brown;
    clear: left;
}

div {
    font-size: 20px;
    font-family: monospace;

    padding: 10px;
    margin-right: 20px;
    border: 5px solid black;
}

&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the CSS code above, we have five cssRule which is declared inside a stylesheet object. The stylesheet object, in this case, is in the &amp;lt; style &amp;gt; tag.&lt;/p&gt;

&lt;p&gt;Now let’s see how we can return each cssRule with JavaScript.&lt;/p&gt;

&lt;p&gt;Type and run the JavaScript code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stylesheet = document.styleSheets[0].cssRules;
console.log(stylesheet);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AjlMNS7uZhfaLPehN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AjlMNS7uZhfaLPehN.png" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As indicated by the yellow, see each property on the console.&lt;/p&gt;

&lt;p&gt;ownerNode&lt;/p&gt;

&lt;p&gt;The ownerNode of the CSSStyleSheet interface lets you return the stylesheet object in the document.&lt;/p&gt;

&lt;p&gt;Try the code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stylesheet = document.styleSheets[0].ownerNode;
console.log(stylesheet);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AiOz0fZh1tHXvnG8S.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AiOz0fZh1tHXvnG8S.png" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we make use of the &amp;lt; style &amp;gt; tag as our stylesheet object. This becomes the ownerNode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Methods&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;deleteRule()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;deleteRule()&lt;/em&gt; method of the CSSStyleSheet interface lets you remove a cssRule within the stylesheet object.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stylesheet.deleteRule(0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the JavaScript code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const removeRule = document.styleSheets[0];
removeRule.deleteRule(1)

 console.log(removeRule.cssRules.length);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AFIWoQ1LzUB7plYWW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AFIWoQ1LzUB7plYWW.png" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we have an output of 4 as the return number.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;insertRule()&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;insertRule()&lt;/em&gt; method of the CSSStyleSheet interface lets you insert a new cssRule within the stylesheet object.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stylesheet.insertRule(rule)
stylesheet.insertRule(rule, index)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Try the JavaScript code below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addRule = document.styleSheets[0];
addRule.insertRule('p { color: red; }', 1);

console.log(addRule.cssRules.length);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the JavaScript code example above, we insert the insertRule(); and then insert the p {color: red;} cssRule in the index 1 of the stylesheet object.&lt;/p&gt;

&lt;p&gt;Making the total length of the cssRule 6 instead of 5. Now let’s check the browser output.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Aa74LnVyDFORhjkwl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Aa74LnVyDFORhjkwl.png" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, the number 6 printout is the total length of the cssRuleList.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSSRule
&lt;/h2&gt;

&lt;p&gt;In this section, we’ll discuss the &lt;em&gt;cssRules&lt;/em&gt; of the &lt;em&gt;CSSStyleSheet&lt;/em&gt; interface in CSS Object Model that allows you to represent a single code block of a stylesheet object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Properties&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The cssText instance property of the cssRule interface returns the cssRule as plain text.&lt;/p&gt;

&lt;p&gt;Try the code example below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main {

    width: 400px;
    height: 100px;
}

.p{
    background: purple;
    color: white;  
}

.one {
    float: right;
}

.two {
    background-color: brown;
    clear: left;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const printRule = document.styleSheets[0];
console.log(printRule.cssRules[1].cssText);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the browser output, we used the cssText property to access the second cssRule from the stylesheet object of the current document. The 1 integer used represents the second index.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A7oK3DMvcfTK8tMle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A7oK3DMvcfTK8tMle.png" width="800" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have the second cssRule printed out from the console output.&lt;/p&gt;

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

&lt;p&gt;The parentRule instance property of the cssRule interface returns the cssMediaRule. If this is not present, it returns a null.&lt;/p&gt;

&lt;p&gt;Try the code example below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (min-width: 900px) {
   .header {
    display: flex;
    flex-direction: column;
    justify-self: unset;
    }
}

main {

    width: 400px;
    height: 100px;
}

.p{
    background: purple;
    color: white;  
}

.one {
    float: right;
}

.two {
    background-color: brown;
    clear: left;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We have added the media queries to a class of .header, which takes a display of flex, a flex-direction of column and justify-self of unset.&lt;/p&gt;

&lt;p&gt;Now let’s see how we can return the CSSMediaRule using the parentRule.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getRuleList = document.styleSheets[0].cssRules;
const getRules = getRuleList[0].cssRules;

console.log(getRules[0].parentRule);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AuAtQyxHDn0CbZFWO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AuAtQyxHDn0CbZFWO.png" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we logged out of the CSSMediaRule.&lt;/p&gt;

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

&lt;p&gt;The parentStyleSheet instance property of the cssRule interface returns the CSSStyleSheet interface object where cssRule is defined in.&lt;/p&gt;

&lt;p&gt;Type and run the code below:&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getRuleList = document.styleSheets[0].cssRules;
const getParent = getRuleList[0].cssRules;
console.log(getParent[0].parentStyleSheet);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code above, we are accessing the &lt;em&gt;cssRuleList&lt;/em&gt; and returning the &lt;em&gt;parentStyleSheet&lt;/em&gt; of the &lt;em&gt;cssRule&lt;/em&gt;, which is a &lt;em&gt;CSSStyleSheet&lt;/em&gt; object.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A_jY26uCERKmqFeYE.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A_jY26uCERKmqFeYE.png" width="800" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We logged out the parent stylesheet object, the CSSStyleSheet interface, from the console output.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSSMediaRule
&lt;/h2&gt;

&lt;p&gt;An important rule in the CSS Object Model is the &lt;em&gt;CSSMediaRule&lt;/em&gt; interface that represents a single CSS &lt;a class="mentioned-user" href="https://dev.to/media"&gt;@media&lt;/a&gt; rule of the CSS at-rule object. It takes a condition and a statement; when the condition is met, the statement is returned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Properties&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The &lt;em&gt;CSSMediaRule.media&lt;/em&gt; instance property of the &lt;em&gt;CSSMediaRule&lt;/em&gt; interface returns a &lt;em&gt;MediaList&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Try the code example below.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @media (min-width: 900px) {
    .header {
    display: flex;
    flex-direction: column;
    justify-self: unset;
    }
}

main {

    width: 400px;
    height: 100px;
}

.p{
    background: purple;
    color: white;  
}

.one {
    float: right;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let getMedia = document.styleSheets[0].cssRules;
console.log(getMedia[0].media);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We are using the &lt;em&gt;media&lt;/em&gt; property to return the first &lt;em&gt;mediaRule&lt;/em&gt; from the MediaList of CSSMediaRule&lt;br&gt;
Interface.&lt;/p&gt;

&lt;p&gt;Now let’s take a look at the console for output.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AgESnUwwz7bjdhW3R.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AgESnUwwz7bjdhW3R.png" width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we have the first mediaRule logged out, an index at 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSSKeyframeRule
&lt;/h2&gt;

&lt;p&gt;CSS keyframes are one of the kinds of animations used in the CSS Object Model that represents a set of CSS rules for a given keyframe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Properties:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;keyText&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;0% to 100% (This will have an index of 0 and 1 and a length of 2)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;CSSKeyframeRule.KeyText&lt;/em&gt; instance property returns the &lt;em&gt;CSSKeyframesRule&lt;/em&gt; selector. Which range from 0% to 100%. Each selector can be accessed by specifying a value based on the index of the selector. For example, a keyframe selector might range from the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;0%, 50% to 100% (This will have an index of 0, 1, and 2 and a length of 3)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;0%, 40%, 80% to 100% (This will have an index of 0, 1, 2 and 4 and a length of 4)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will largely depend on the number of ranges(%) available.&lt;/p&gt;

&lt;p&gt;Try the code example below,&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframes animate {
  0% {
    background-color: red;
  }

  50% {
    background-color: green;
  }

  100% {
    background-color: blue;
  }
}

main {

    width: 400px;
    height: 100px;
    animation: animate 5s infinite;
}

.p{
    background: purple;
    color: white;  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let getKeyframes = document.styleSheets[0].cssRules;
let returnKey = getKeyframes[0];
console.log(returnKey[2].keyText);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code example above, we are accessing the first CSSKeyframeRule by using the 0 indexes at the getKeyframes[0] and returning the last selector, 100%, by specifying the index value 2 at returnKey[2].keyText.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AHCoPgpXUtAEyfbBf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AHCoPgpXUtAEyfbBf.png" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we logged the &lt;em&gt;100%&lt;/em&gt; selector using the &lt;em&gt;keyText&lt;/em&gt; from the &lt;em&gt;CSSKeyframeRule&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;While working with CSS, web developers can leverage some of the &lt;a href="https://www.lambdatest.com/blog/best-css-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;best CSS frameworks&lt;/a&gt; to create user-friendly and &lt;a href="https://www.lambdatest.com/blog/how-to-make-a-cross-browser-compatible-website/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;browser-compatible websites&lt;/a&gt; and web pages. CSS Frameworks provide a solid foundation for developers to build upon and can save time and effort in the development process.&lt;/p&gt;

&lt;p&gt;Further, with LambdaTest’s cross browser testing cloud, devs and QA can perform real-time testing and ensure their CSS-developed web applications render perfectly across multiple browsers environments.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WYbyLfLM2-E"&gt;
&lt;/iframe&gt;
&lt;br&gt;
You can also subscribe to our &lt;a href="https://www.youtube.com/@LambdaTest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&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=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&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=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&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=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar15_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Testing&lt;/a&gt; scripts on the LambdaTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We just covered a complete guide to CSS Object Model (CSSOM) covering topics on styling DOM elements, different CSS style interfaces, and different rules used in the CSS Object Model. Using the CSS Object Model, developers can create more sophisticated and interactive websites. With this guide, developers can use the CSS Object Model to improve their web applications and build more engaging user interfaces to provide a seamless user experience. 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;p&gt;&lt;strong&gt;#LambdaTestYourApps&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.What is the DOM model in CSS?
&lt;/h3&gt;

&lt;p&gt;A programming interface called the DOM (Document Object Model) is used in web development to show the structure of an HTML or XML document as a hierarchical tree. Developers can create dynamic and aesthetically pleasing web pages by selecting particular elements in the tree and applying styling rules to them using the DOM model in CSS.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. How do DOM and CSS Object Model work?
&lt;/h3&gt;

&lt;p&gt;A programming interface for web documents called Document Object Model (DOM) represents a page as a hierarchical tree structure. The interface used to modify the styling of elements in the DOM tree is the CSS Object Model (CSSOM). The DOM and CSS Object Model enable developers to change the content and styling of the page using JavaScript and CSS, resulting in dynamic web pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.How is the CSS Object Model constructed?
&lt;/h3&gt;

&lt;p&gt;By combining CSS files with the DOM tree and parsing CSS files, the CSS Object Model is created. Each document’s CSS Object Model, which the browser creates, contains all the rules applied to the elements in the DOM tree. The browser can render the website using the specified styles thanks to this process.&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Mastering CSS Border Style: A Comprehensive Guide</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Fri, 03 Mar 2023 15:24:45 +0000</pubDate>
      <link>https://forem.com/testmuai/mastering-css-border-style-a-comprehensive-guide-48k4</link>
      <guid>https://forem.com/testmuai/mastering-css-border-style-a-comprehensive-guide-48k4</guid>
      <description>&lt;p&gt;CSS Borders refers to the line outside the &lt;strong&gt;padding&lt;/strong&gt; and inside the &lt;strong&gt;margin&lt;/strong&gt; of the CSS Box Model. This line wraps around the padding and content in every HTML Element. That is both semantic and non-semantic elements.&lt;/p&gt;

&lt;p&gt;Borderlines don’t have to be a solid straight line. We can apply different styles to it to change its looks and feel, as you will see as we learn more about it in this blog on CSS Borders.&lt;/p&gt;

&lt;p&gt;Understanding how to use CSS Borders can improve our work with web elements. In this blog on CSS Borders, you will learn how to utilize CSS to generate and customize borders.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to CSS Borders
&lt;/h2&gt;

&lt;p&gt;Since borders separate between padding and margin, CSS Borders can be used as a good color contrast between a web element and the web page’s background. For instance, if the background color of a web page is light in value, we can simply apply a dark or slightly darker color to a border of a particular web element on the web page. This will help provide a good visual contrast.&lt;/p&gt;

&lt;p&gt;A good example of web elements we can apply borders to are buttons, cards, form fields, etc. The image below shows us how we can work with borders.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AmOb852h1hWpYT5_U.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AmOb852h1hWpYT5_U.jpg" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A quick look at the CSS Box Model should give us an idea of where the border can be found and what it looks like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AEyJNe_bp6SjUTfH7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AEyJNe_bp6SjUTfH7.jpg" width="651" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the above illustration, you will notice that the &lt;strong&gt;border&lt;/strong&gt; sits on top of the &lt;strong&gt;padding&lt;/strong&gt; and, at the same time, below the &lt;strong&gt;margin&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As you’ll soon notice, the CSS &lt;strong&gt;border&lt;/strong&gt; property is a shorthand property meant to declare all the border properties in a single instance without including other sub-properties.&lt;/p&gt;

&lt;p&gt;For clarity purposes, we’ll learn how to use each property associated with the CSS &lt;strong&gt;border&lt;/strong&gt; property, which includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;border-width&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;border-color&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;border-styles&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;border-radius&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;border-image&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sub-properties are very useful for targeting individual properties and can improve how you style your web elements; when you understand how it works.&lt;/p&gt;

&lt;p&gt;The CSS &lt;strong&gt;border&lt;/strong&gt; property should not be confused with the CSS &lt;strong&gt;outline&lt;/strong&gt; property, THEY ARE NOT THE SAME THING.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ACZssbnMiHwPq8pxA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ACZssbnMiHwPq8pxA.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Perform manual or automated cross &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;browser test&lt;/a&gt; on 3000+ browsers online. Deploy and scale faster with the most powerful cross browser testing tool online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Border-style property
&lt;/h2&gt;

&lt;p&gt;This property is used to set the style or decoration of the border of a web element. This property takes in the predefined values of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Solid&lt;/strong&gt;: sets a single straight line around a web element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dashed&lt;/strong&gt;: sets a series of dashes (short hyphenated straight lines) around a web element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dotted&lt;/strong&gt;: sets a series of rounded dots around a web element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hidden&lt;/strong&gt;: hides the border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Doubled&lt;/strong&gt;: sets two straight lines around a web element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Groove&lt;/strong&gt;: sets a carved-out 3D appearance. This is the opposite of the ridge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ridge&lt;/strong&gt;: sets an extrude in 3D appearance. This is the opposite of the groove.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Inset&lt;/strong&gt;: sets an embedded 3D appearance. This is the opposite of the outset.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Outset&lt;/strong&gt;: sets an embossed 3D appearance. This is the opposite of the inset.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;None&lt;/strong&gt;: removes the border. Behaves just like the hidden value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s important to note that without the border-style property defined, other CSS Border properties, such as &lt;strong&gt;&lt;em&gt;border-width, border-color, border-radius,&lt;/em&gt;&lt;/strong&gt; etc., will not take effect. So the border should always be defined.&lt;/p&gt;

&lt;p&gt;For a better understanding, see the illustration below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ABe5OFnNxzg79E2HR.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ABe5OFnNxzg79E2HR.jpg" width="651" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s see how we can apply this using code.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;body&amp;gt;

    &amp;lt;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;section class="b dotted"&amp;gt;border with dotted&amp;lt;/section&amp;gt;
            &amp;lt;section class="b solid"&amp;gt;border with solid&amp;lt;/section&amp;gt;
            &amp;lt;section class="b dashed"&amp;gt;border with dashed&amp;lt;/section&amp;gt;
            &amp;lt;section class="b hidden"&amp;gt;border with hidden&amp;lt;/section&amp;gt;
            &amp;lt;section class="b doubled"&amp;gt;border with double&amp;lt;/section&amp;gt;
            &amp;lt;section class="b groove"&amp;gt;border with groove&amp;lt;/section&amp;gt;
            &amp;lt;section class="b ridge"&amp;gt;border with ridge&amp;lt;/section&amp;gt;
            &amp;lt;section class="b inset"&amp;gt;border with inset&amp;lt;/section&amp;gt;
            &amp;lt;section class="b outset"&amp;gt;border with outset&amp;lt;/section&amp;gt;
            &amp;lt;section class="b none"&amp;gt;border with none&amp;lt;/section&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
    &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .dotted {
        border-style: solid;
        border-top-width: 2px;
        border-color: black;
    }

    .bottom {
        border-style: bottom;
        border-bottom-width: 2px;
    }

    .solid {
        border-style: solid;
        border-left-width: 2px;
    }

    .dashed{
        border-style: dashed;
        border-right-width: 2px;
    }

    .hidden {
        border-style: hidden;
        border-right-width: 9px;
    }

    .doubled {
        border-style: double;
        border-right-width: 2px;
    }

    .groove {
        border-style: groove;
        border-right-width: 2px;
    }

    .ridge {
        border-style: ridge;
        border-right-width: 2px;
    }

    .inset {
        border-style: inset;
        border-right-width: 2px;
    }

    .outset {
        border-style: outset;
        border-right-width: 2px;
    }

    .none {
        border-style: none;
        border-right-width: 2px;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AJi4IkI1sJi9v2siv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AJi4IkI1sJi9v2siv.png" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Need a great solution for cross browser testing on Safari? Forget about emulators or simulators — use real online browsers. Try LambdaTest to test on &lt;a href="https://www.lambdatest.com/test-on-safari-browsers?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;safari browser online&lt;/a&gt;!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sub properties of border style
&lt;/h2&gt;

&lt;p&gt;The CSS &lt;strong&gt;border-style&lt;/strong&gt; property is a shorthand for the following properties below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-top-style&lt;/strong&gt;: sets the line style of the web element’s top border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-bottom-style&lt;/strong&gt;: sets the line style of the web element’s bottom border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-left-style&lt;/strong&gt;: sets the line style of the web element’s left border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-right-style&lt;/strong&gt;: sets the line style of the web element’s right border.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we use the CSS &lt;strong&gt;border-style&lt;/strong&gt; property, any value assigned automatically targets the four corners of the web element’s border, &lt;strong&gt;top&lt;/strong&gt;, &lt;strong&gt;bottom&lt;/strong&gt;, &lt;strong&gt;left&lt;/strong&gt;, and &lt;strong&gt;right&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So when we need to style one corner of the web element, we can use the sub-properties designed to handle this task.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;section class="b top"&amp;gt;border-top-style&amp;lt;/section&amp;gt;
            &amp;lt;section class="b bottom"&amp;gt;border-bottom-style&amp;lt;/section&amp;gt;
            &amp;lt;section class="b left"&amp;gt;border-left-style&amp;lt;/section&amp;gt;
            &amp;lt;section class="b right"&amp;gt;border-right-style&amp;lt;/section&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .top {
        border-top-style: solid;
    }

    .bottom{
        border-bottom-style: dashed;
    }

    .left {
        border-left-style: dotted;
    }

    .right {
        border-right-style: double;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AGf2K0NJkCt2mbe3K.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AGf2K0NJkCt2mbe3K.png" width="736" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Test your CSS Borders across 3000+ real browsers and OS. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Border-width property
&lt;/h2&gt;

&lt;p&gt;This property is used to set the size of the border width, and to do this, we can either use the &lt;strong&gt;keyword values&lt;/strong&gt; or &lt;strong&gt;length values&lt;/strong&gt; associated with the CSS &lt;strong&gt;border&lt;/strong&gt; property.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keyword Values&lt;/strong&gt;: thin, medium, thick. (these are predefined values). These values are fixed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Length Value&lt;/strong&gt;: rem, em, pt, %, px (These are CSS units). These values are not fixed. We can be creative and determine how big or small we want the width to appear.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;section class="b thin"&amp;gt;A border with thin line&amp;lt;/section&amp;gt;
            &amp;lt;section class="b medium"&amp;gt;A border with medium line&amp;lt;/section&amp;gt;
            &amp;lt;section class="b thick"&amp;gt;A border with thick line&amp;lt;/section&amp;gt;
            &amp;lt;section class="b px"&amp;gt;A border using the CSS px unit&amp;lt;/section&amp;gt;
            &amp;lt;section class="b rem"&amp;gt;A border using the CSS rem unit&amp;lt;/section&amp;gt;
            &amp;lt;section class="b percentage"&amp;gt;A border using the CSS %    unit&amp;lt;/section&amp;gt;
            &amp;lt;section class="b no-style"&amp;gt;border style is not defined&amp;lt;/section&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;    .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .thin {
        border-style: solid;
        border-width: thin;
    }

    .medium {
        border-style: solid;
        border-width: medium;
    }

    .thick {
        border-style: solid;
        border-width: thick;
    }

    .px {
        border-style: solid;
        border-width: 7px;
    }

    .rem {
        border-style: solid;
        border-width: 0.07rem;
    }

    .percentage {
        border-style: solid;
        border-width: 3%;
    }

    .no-style {
        border-width: 7px;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALKdp2klHJwLll-04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALKdp2klHJwLll-04.png" width="487" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, you’ll notice the fourth element has the largest border width on the webpage compared to the others. This is because we will assign it a &lt;strong&gt;width&lt;/strong&gt; of &lt;strong&gt;7px&lt;/strong&gt;, but we can make it larger if we want, as long as we use CSS units (such as px, rem, em, %, etc.)&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Sub properties of border width
&lt;/h2&gt;

&lt;p&gt;While the &lt;strong&gt;px&lt;/strong&gt; CSS unit is absolute, changes from the web element do not directly affect it, unlike the &lt;strong&gt;rem&lt;/strong&gt; and &lt;strong&gt;em&lt;/strong&gt;, which are relative to the HTML root and parent elements. For example, the &lt;strong&gt;width&lt;/strong&gt; of &lt;strong&gt;7px&lt;/strong&gt; we assigned to our border will still be stuck at 7px if the user by any means decides to increase or decrease the browser font size, but using units like &lt;strong&gt;rem&lt;/strong&gt; and &lt;strong&gt;em&lt;/strong&gt;, which are relative scale better to fit the new adjusted size of the browser. This is great for accessibility and responsive design.&lt;/p&gt;

&lt;p&gt;The keyword values (thin, medium, and thick) only give us a fixed &lt;strong&gt;width&lt;/strong&gt;, which has already been predefined.&lt;/p&gt;

&lt;p&gt;As you have seen, the last element does not have a border width. This is because we do not assign a CSS &lt;strong&gt;border-style&lt;/strong&gt; to the element. Border-style &lt;strong&gt;(border-style)&lt;/strong&gt; is required to make the border appear in every element.&lt;/p&gt;

&lt;p&gt;The CSS border-width property is a shorthand for the following properties below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-top-width:&lt;/strong&gt; sets the line width of the web element’s top border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-bottom-width:&lt;/strong&gt; sets the line width of the web element’s bottom border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-left-width:&lt;/strong&gt; sets the line width of the web element’s left border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-right-width:&lt;/strong&gt; sets the line width of the web element’s right border.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As we’ve seen before, from the CSS &lt;strong&gt;border-style&lt;/strong&gt; property, any value assigned to CSS &lt;strong&gt;border-width&lt;/strong&gt; automatically targets the four corners of the web element’s border, &lt;strong&gt;top&lt;/strong&gt;, &lt;strong&gt;bottom&lt;/strong&gt;, &lt;strong&gt;left&lt;/strong&gt;, and &lt;strong&gt;right&lt;/strong&gt; respectively.&lt;/p&gt;

&lt;p&gt;So to target each corner individually, the border-width sub-properties should be used.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
            &amp;lt;div class="box"&amp;gt;
                &amp;lt;section class="b top"&amp;gt;A border top width&amp;lt;/section&amp;gt;
                &amp;lt;section class="b bottom"&amp;gt;A border bottom width&amp;lt;/section&amp;gt;
                &amp;lt;section class="b left"&amp;gt;A border left width&amp;lt;/section&amp;gt;
                &amp;lt;section class="b right"&amp;gt;A border right width&amp;lt;/section&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .top {
        border-style: solid;
        border-top-width: 9px;
    }

    .bottom {
        border-style: solid;
        border-bottom-width: 9px;
    }

    .left {
        border-style: solid;
        border-left-width: 9px;
    }

    .right {
        border-style: solid;
        border-right-width: 9px;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AP_LGcqcNtyrI90EU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AP_LGcqcNtyrI90EU.png" width="697" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output we assign a &lt;strong&gt;width&lt;/strong&gt; of &lt;strong&gt;9px&lt;/strong&gt; to the &lt;strong&gt;top&lt;/strong&gt;, &lt;strong&gt;bottom&lt;/strong&gt;, &lt;strong&gt;left&lt;/strong&gt; and &lt;strong&gt;right&lt;/strong&gt; of each element.&lt;/p&gt;

&lt;h2&gt;
  
  
  Border-color property
&lt;/h2&gt;

&lt;p&gt;From the browser output we assign a &lt;strong&gt;width&lt;/strong&gt; of &lt;strong&gt;9px&lt;/strong&gt; to the &lt;strong&gt;top&lt;/strong&gt;, &lt;strong&gt;bottom&lt;/strong&gt;, &lt;strong&gt;left&lt;/strong&gt; and &lt;strong&gt;right&lt;/strong&gt; of each element.&lt;br&gt;
This property is used to set the color of the element’s border.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;section class="b green"&amp;gt;A border with green color&amp;lt;/section&amp;gt;
            &amp;lt;section class="b red"&amp;gt;A border with red color&amp;lt;/section&amp;gt;
            &amp;lt;section class="b rgb1"&amp;gt;A border with rgb color value&amp;lt;/section&amp;gt;
            &amp;lt;section class="b rgb2"&amp;gt;A border with rgb color value&amp;lt;/section&amp;gt;
            &amp;lt;section class="b hexcode1"&amp;gt;
               A border with hexcode color value
            &amp;lt;/section&amp;gt;
            &amp;lt;section class="b hexcode2"&amp;gt;
              A border with hexcode color value
            &amp;lt;/section&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .green {
        border-style: solid;
        border-width: 9px;
        border-color: green;
    }

    .red {
        border-style: solid;
        border-width: 9px;
        border-color: red;
    }

    .rgb1 {
        border-style: solid;
        border-width: 9px;
        border-color: rgb(32, 113, 128);
    }

    .rgb2 {
        border-style: solid;
        border-width: 9px;
        border-color: rgb(231, 248, 76) ;
    }

    .hexcode1 {
            border-style: solid;
            border-width: 9px;
            border-color:#1301b3 ;
    }

    .hexcode2 {
        border-style: solid;
        border-width: 9px;
        border-color: #0d0b25;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2006%2F0%2A_aekfIVe5PeXRP-f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2006%2F0%2A_aekfIVe5PeXRP-f.png" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, we applied colors to the border of the elements on the web page using color keyword, rgb, and hexcode values.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;**Check this out: Are you using &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; for automation testing? Run your Playwright test scripts instantly on 50+ browser/OS combinations using the LambdaTest cloud. *&lt;/em&gt;*&lt;/p&gt;

&lt;h2&gt;
  
  
  Sub properties of border color
&lt;/h2&gt;

&lt;p&gt;The CSS &lt;strong&gt;border-color&lt;/strong&gt; property is a shorthand for the following properties below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-top-color:&lt;/strong&gt; sets the color of the web element’s top border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-bottom-color:&lt;/strong&gt; sets the color of the web element’s bottom border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-left-color:&lt;/strong&gt; sets the color of the web element’s left border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-right-color:&lt;/strong&gt; sets the color of the web element’s right border.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The CSS &lt;strong&gt;border-color&lt;/strong&gt; property, any value assigned to the CSS &lt;strong&gt;border-color&lt;/strong&gt; automatically targets the four corners of the web element’s border, &lt;strong&gt;top&lt;/strong&gt;, &lt;strong&gt;bottom&lt;/strong&gt;, &lt;strong&gt;left&lt;/strong&gt;, and &lt;strong&gt;right&lt;/strong&gt;, respectively.&lt;/p&gt;

&lt;p&gt;We use these sub-properties when there is a need to target individual borders and apply different colors.&lt;/p&gt;

&lt;p&gt;For better understanding, let’s see this in action.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
            &amp;lt;div class="box"&amp;gt;
                &amp;lt;section class="b top"&amp;gt;A border top color&amp;lt;/section&amp;gt;
                &amp;lt;section class="b bottom"&amp;gt;A border bottom color&amp;lt;/section&amp;gt;
                &amp;lt;section class="b left"&amp;gt;A border left color&amp;lt;/section&amp;gt;
                &amp;lt;section class="b right"&amp;gt;A border right color&amp;lt;/section&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/main&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .top {
        border-style: solid;
        border-width: 9px;
        border-top-color: green;
    }

    .bottom {
        border-style: solid;
        border-width: 9px;
        border-bottom-color: red;
    }

    .left {
        border-style: solid;
        border-width: 9px;
        border-left-color: rgb(32, 113, 128);
    }

    .right {
        border-style: solid;
        border-width: 9px;
        border-right-color: rgb(231, 248, 76) ;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AfybCFgC1hQv1HG8u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AfybCFgC1hQv1HG8u.png" width="709" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, we created four separate div tags, and we applied a CSS &lt;strong&gt;border-style&lt;/strong&gt; of &lt;strong&gt;solid&lt;/strong&gt;, &lt;strong&gt;border-width&lt;/strong&gt; of &lt;strong&gt;9px&lt;/strong&gt; and different colors to each element’s border.&lt;/p&gt;

&lt;p&gt;Also, &lt;strong&gt;border-top-color&lt;/strong&gt;, &lt;strong&gt;border-bottom-color&lt;/strong&gt;, &lt;strong&gt;border-left-color&lt;/strong&gt;, and &lt;strong&gt;border-right-color&lt;/strong&gt; are applied to different corners of each web element, respectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Border-radius property
&lt;/h2&gt;

&lt;p&gt;This property is used to apply a round corner effect to an element’s outer edge or border.&lt;/p&gt;

&lt;p&gt;Unlike the other CSS &lt;strong&gt;border&lt;/strong&gt; properties, the CSS &lt;strong&gt;border-radius&lt;/strong&gt; property takes effect with or without an element border. You also don’t need to define a CSS &lt;strong&gt;border-style&lt;/strong&gt; property for the CSS border-radius property to work.&lt;/p&gt;

&lt;p&gt;The code below shows us how this works.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;section class="b square"&amp;gt;A square with a border-radius&amp;lt;/section&amp;gt;
            &amp;lt;section class="b cirle"&amp;gt;A circle with a border-radius&amp;lt;/section&amp;gt;
            &amp;lt;section class="b rectangle"&amp;gt;A rectangle with a border-radius&amp;lt;/section&amp;gt;

        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .square {
        width: 150px;
        height: 150px;
        color: white;
        background-color: skyblue;
        border-radius: 12px;
    }

    .circle {
        width: 150px;
        height: 150px;
        color: white;
        background-color: coral;
        border-radius: 50%;
    }

    .rectangle {
        width: 400px;
        height: 100px;
        color: white;
        background-color: darkmagenta;
        border-radius: 0px 20px;
        border: 9px solid #000;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AE19G1qKu6zaBZAXi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AE19G1qKu6zaBZAXi.png" width="709" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CSS &lt;strong&gt;border-radius&lt;/strong&gt; property is very different when we apply it to an element. It rounds the four corners of the element even when the said element &lt;strong&gt;border&lt;/strong&gt; is set to &lt;strong&gt;hidden&lt;/strong&gt; or &lt;strong&gt;none&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;From the browser’s output, you’ll notice that the three elements have different shapes. The first square takes in &lt;strong&gt;width&lt;/strong&gt; and &lt;strong&gt;height&lt;/strong&gt; of &lt;strong&gt;150px&lt;/strong&gt; on both sides and a CSS &lt;strong&gt;border-radius&lt;/strong&gt; of &lt;strong&gt;12px&lt;/strong&gt;, leading to a round corner effect.&lt;/p&gt;

&lt;p&gt;The second element, which happens to be a circle, is set to the same &lt;strong&gt;width&lt;/strong&gt; and &lt;strong&gt;height **of **150px&lt;/strong&gt; but this time, a CSS &lt;strong&gt;border-radius of 50%&lt;/strong&gt; . This creates a circle effect of the element.&lt;/p&gt;

&lt;p&gt;While the third one is a rectangle, which takes in a &lt;strong&gt;width&lt;/strong&gt; of &lt;strong&gt;400px&lt;/strong&gt; and a &lt;strong&gt;height&lt;/strong&gt; of &lt;strong&gt;100px&lt;/strong&gt;. The CSS &lt;strong&gt;border-radius&lt;/strong&gt; is set to &lt;strong&gt;0px&lt;/strong&gt; on the top-left and bottom-right while &lt;strong&gt;20px&lt;/strong&gt; on the &lt;strong&gt;top-right&lt;/strong&gt; and &lt;strong&gt;bottom-right&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Also, we introduced a &lt;strong&gt;border&lt;/strong&gt; and set the &lt;strong&gt;width&lt;/strong&gt; to &lt;strong&gt;9px&lt;/strong&gt; across, a &lt;strong&gt;style&lt;/strong&gt; of &lt;strong&gt;solid&lt;/strong&gt; and a &lt;strong&gt;color&lt;/strong&gt; of &lt;strong&gt;black&lt;/strong&gt;. Notice how this is done in one line of code. In this tutorial on CSS Borders, we’ll explain how this is done in the upcoming chapter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: A comprehensive &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end to end Testing&lt;/a&gt; tutorial that covers what E2E Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sub properties of border radius
&lt;/h2&gt;

&lt;p&gt;We’ve talked about shorthand property before, the CSS &lt;strong&gt;border-radius&lt;/strong&gt; is a &lt;strong&gt;shorthand&lt;/strong&gt; property for the following properties below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-top-left-radius:&lt;/strong&gt; sets the radius of the web element’s top-left border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-top-right-radius:&lt;/strong&gt; sets the radius of the web element’s top-right border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-bottom-right-radius:&lt;/strong&gt; sets the radius of the web element’s bottom-right border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-bottom-left-radius:&lt;/strong&gt; sets the radius of the web element’s bottom-left border.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
            &amp;lt;div class="box"&amp;gt;
                &amp;lt;section class="b top-left"&amp;gt;
                  A border radius for top-left border
                &amp;lt;/section&amp;gt;
                &amp;lt;section class="b top-right"&amp;gt;
                  A border radius for top-right border
                &amp;lt;/section&amp;gt;
                &amp;lt;section class="b bottom-right"&amp;gt;
                   A border radius for bottom-right border
                &amp;lt;/section&amp;gt;
                &amp;lt;section class="b bottom-left"&amp;gt;
                   A border radius for bottom-left border
                &amp;lt;/section&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/main&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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; .b {
        background-color: rgb(240, 181, 181);
        width: 300px;
        margin: 20px;
    }

    .top-left {
        width: 400px;
        height: 50px;
        color: white;
        background-color: rgb(0, 157, 219);
        border-top-left-radius: 12px;
    }

    .top-right {
        width: 400px;
        height: 50px;
        color: white;
        background-color: rgb(15, 81, 107);
        border-top-right-radius: 12px;
    }

    .bottom-right {
        width: 400px;
        height: 50px;
        color: white;
        background-color: rgb(15, 19, 252);
        border-bottom-right-radius: 12px;
    }

    .bottom-left {
        width: 400px;
        height: 50px;
        color: white;
        background-color: rgb(3, 4, 85);
        border-bottom-left-radius: 12px;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A9cOYSaZSFew3ielx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A9cOYSaZSFew3ielx.png" width="697" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Applying CSS border-radius is very popular in web design and development. Understanding and using this property effectively will improve your design elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Border-image property
&lt;/h2&gt;

&lt;p&gt;This property is used to set an image as the border of an element in place of a borderline.&lt;/p&gt;

&lt;p&gt;This property can be used to declare all the border image sub-properties in one line of code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&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;  border-image: url(“/folder/image.jpg”) 16 / 40px / 10px stretch;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just like most of the border property, the CSS &lt;strong&gt;border-image&lt;/strong&gt; property is a shorthand property for the following properties.&lt;/p&gt;

&lt;p&gt;We will use the following images from Unsplash; you can download them here: Image1, Image2, and Image3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Are you using Playwright for automation testing? Run your &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright test&lt;/a&gt; scripts instantly on 50+ browser/OS combinations using the LambdaTest cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  border-image-source
&lt;/h2&gt;

&lt;p&gt;Used to set the image path to be used.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;div class=”b two”&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;  .two {
        width: 100px;
        height: 100px;
        background-color: lime;
        border-image-source: url("/flower2.jpg");
        border-image-width: 40px;
        border-style: solid;
        border-color: transparent;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A0GllUrLp__pCc4lZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A0GllUrLp__pCc4lZ.png" width="700" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the code sample above, we use the CSS &lt;strong&gt;border-image-source&lt;/strong&gt; property to apply an image to the element border. We also apply a CSS &lt;strong&gt;border-images-width&lt;/strong&gt; of &lt;strong&gt;40px&lt;/strong&gt;; we’ll explain how this works shortly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: This &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright automation&lt;/a&gt; tutorial will guide you through the setup of the Playwright framework, which will enable you to write end-to-end tests for your future projects.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  border-image-width
&lt;/h2&gt;

&lt;p&gt;Used to set the width of the border image. It takes integers as values in four places: the top, bottom, left, and right.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;div class="b one"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b two"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b three"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b four"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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; .b {
        background-color: rgb(240, 181, 181);
        margin: 10px;
    }

    .one {
        width: 100px;
        height: 100px;
        background-color: red;
        border-image: url("/flower.jpg") 90 repeat stretch;
        border-image-width: 10px;
        border-style: dotted;
        border-color: transparent;
    }

    .two {
        width: 100px;
        height: 100px;
        background-color: lime;
        border-image: url("/flower2.jpg") 40% round ;
        border-image-width: 30px 10px;
        border-style: solid;
        border-color: transparent;
    }

    .three {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image: url("/flower3.jpg") 90 repeat stretch;
        border-image-width: 50px;
        border-style: double;
        border-color: transparent;
    }

    .four {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image: url("/flower3.jpg") 90 repeat stretch;
        border-width: 50px;
        border-style: double;
        border-color: transparent;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AJPpJE8S0cGbvfkdJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AJPpJE8S0cGbvfkdJ.png" width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the code sample above, we created four div tags with a &lt;strong&gt;width **and **height&lt;/strong&gt; of &lt;strong&gt;100px&lt;/strong&gt; across. We apply a border image to each div tag. These images are set to a different width with the CSS &lt;strong&gt;border-image-width&lt;/strong&gt; property, which affects the structure of the elements, as you can see from the browser output.&lt;/p&gt;

&lt;p&gt;The first element takes in a &lt;strong&gt;border-image-width&lt;/strong&gt; of &lt;strong&gt;10px&lt;/strong&gt;, this gives the image a &lt;strong&gt;10px&lt;/strong&gt; width around the element. The next element, which is the second one, takes in &lt;strong&gt;30px&lt;/strong&gt; for &lt;strong&gt;top&lt;/strong&gt; and &lt;strong&gt;bottom&lt;/strong&gt; and &lt;strong&gt;10px&lt;/strong&gt; for &lt;strong&gt;left&lt;/strong&gt; and &lt;strong&gt;right&lt;/strong&gt;, while for the third and fourth elements, we applied the same styles to both but different border width properties. The third element takes a CSS &lt;strong&gt;border-image-width&lt;/strong&gt; property, while the four elements take in a CSS &lt;strong&gt;border-width&lt;/strong&gt; property. This is to illustrate the difference between the two properties, so we don’t mistake one for the other.&lt;/p&gt;

&lt;p&gt;The block arrow shows us how the CSS &lt;strong&gt;border-image-width&lt;/strong&gt; affects element structure compared to CSS &lt;strong&gt;border-width&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  border-image-slice
&lt;/h2&gt;

&lt;p&gt;Used to slice up the image used as the border-image into different regions around the element border. It takes integers, keywords, or percentages &lt;strong&gt;(%)&lt;/strong&gt; as values.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;div class="b one"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b two"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b three"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b four"&amp;gt;&amp;lt;/div&amp;gt;
         &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;  .b {
        background-color: rgb(240, 181, 181);
        margin: 10px;
    }

    .one {
        width: 100px;
        height: 100px;
        background-color: red;
        border-image-source: url("/flower.jpg");
        border-image-width: 10px;
        border-style: dotted;
        border-color: transparent;
    }

    .two {
        width: 100px;
        height: 100px;
        background-color: lime;
        border-image-source: url("/flower2.jpg");
        border-image-width: 40px;
        border-style: solid;
        border-color: transparent;
    }

    .three {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-image-width: 50px;
        border-style: double;
        border-color: transparent;
    }

    .four {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-width: 50px;
        border-style: solid;
        border-color: transparent;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AAFbkln4r69FlYuHv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AAFbkln4r69FlYuHv.png" width="800" height="609"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output above, this is how the &lt;strong&gt;border-image&lt;/strong&gt; appears without the CSS border-image-slice property.&lt;/p&gt;

&lt;p&gt;Now let’s look at how the &lt;strong&gt;border-image&lt;/strong&gt; appears when we assign the CSS &lt;strong&gt;border-image-property&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS:&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;  .one {
        border-image-slice: 5;}

    .two {
        border-image-slice: 20%;
    }

    .three {
        border-image-slice: fill;
    }

    .four {
        border-image-slice: 50;;
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALe5ycyBuAT1CZ6-x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALe5ycyBuAT1CZ6-x.png" width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Apart from the third element, which is assigned a value of fill, all other elements had changed from the cross-like shape they had when we first created them from the previous example.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  border-image-repeat
&lt;/h2&gt;

&lt;p&gt;This is used to set how the image is distributed around the element’s border. That is, the images, when assigned their keyword value, will occupy any remaining space around the element’s border by either stretching, rounding, repeating, or spacing.&lt;/p&gt;

&lt;p&gt;For better understanding, type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;div class="b one"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b two"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b three"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b four"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;  .b {
        background-color: rgb(240, 181, 181);
        margin: 10px;
    }

    .one {
        width: 100px;
        height: 100px;
        background-color: red;
        border-image-source: url("/flower.jpg");
        border-image-slice: 5;
        border-image-repeat: space;
        border-image-width: 10px;
        border-style: dotted;
        border-color: transparent;
    }

    .two {
        width: 100px;
        height: 100px;
        background-color: lime;
        border-image-source: url("/flower2.jpg");
        border-image-slice: 20%;
        border-image-repeat: stretch;
        border-image-width: 40px;
        border-style: solid;
        border-color: transparent;
    }

    .three {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-image-width: 20px;
        border-image-repeat: round;
        border-image-slice: 2;
        border-style: double;
        border-color: transparent;
    }

    .four {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-image-slice: 20;
        border-image-repeat: repeat;
        border-width: 50px;
        border-style: solid;
        border-color: transparent;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AkSHQorMUVeAtKzXT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AkSHQorMUVeAtKzXT.png" width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt; from the browser output the different distribution or repetition of the image across the element’s border. The first element has a value of &lt;strong&gt;space&lt;/strong&gt;, which results in space being applied to separate the image into squares. The second element takes a value of &lt;strong&gt;stretch&lt;/strong&gt;, which results in the image stretching across the element’s border. The third element takes a value of &lt;strong&gt;round&lt;/strong&gt;, which results in the rounding of the image across the element’s border, while the four elements take a value of &lt;strong&gt;repeat&lt;/strong&gt;, which results in the image repeating in a square-like manner across the border image.&lt;/p&gt;

&lt;p&gt;We can also assign more than one value to the CSS &lt;strong&gt;border-image-repeat&lt;/strong&gt; property in one line of code.&lt;/p&gt;

&lt;p&gt;Try this example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;div class=”b four”&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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; .four {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-image-slice: 20;
        border-image-repeat: repeat space;
        border-width: 50px;
        border-style: solid;
        border-color: transparent;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aur8f2EKTjBzAA4mV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aur8f2EKTjBzAA4mV.png" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, we added another value of **space **to the fourth element, which resulted in spaces being added to the element **left **and **right **side while the top and bottom retain its initial value of repeat.&lt;/p&gt;

&lt;h2&gt;
  
  
  border-image-outset
&lt;/h2&gt;

&lt;p&gt;This is used to set the distance between the border-image and the element border box.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;div class="b one"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b two"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b three"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="b four"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS:&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;   .b {
        background-color: rgb(240, 181, 181);
        margin: 10px;
    }

    .one {
        width: 100px;
        height: 100px;
        background-color: red;
        border-image-source: url("/flower.jpg");
        border-image-slice: 15;
        border-image-repeat: space;
        border-image-outset: 10px;
        border-image-width: 10px;
        border-style: dotted;
        border-color: transparent;
    }

    .two {
        width: 100px;
        height: 100px;
        background-color: lime;
        border-image-source: url("/flower2.jpg");
        border-image-slice: 20%;
        border-image-repeat: stretch;
        border-image-outset: 0 1rem;
        border-image-width: 40px;
        border-style: solid;
        border-color: transparent;
    }

    .three {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-image-width: 20px;
        border-image-repeat: round;
        border-image-outset: 4;
        border-image-slice: 2;
        border-style: double;
        border-color: transparent;
    }

    .four {
        width: 100px;
        height: 100px;
        background-color: cyan;
        border-image-source: url("/flower3.jpg");
        border-image-slice: 20;
        border-image-repeat: repeat;
        border-image-outset: 10px;
        border-width: 50px;
        border-style: dotted;
        border-color: transparent;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AFEbUVLZ7QjVfpSv9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AFEbUVLZ7QjVfpSv9.png" width="800" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser out, the first element gives us a perfect example of how the CSS &lt;strong&gt;border-image-outset&lt;/strong&gt; property works, as you can see how the four square boxes shoot out from the border box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Border (Shorthand property)
&lt;/h2&gt;

&lt;p&gt;This sets all the border sub-properties in one line of code.&lt;/p&gt;

&lt;p&gt;The example below shows us how this works. By creating a simple Click Me button project, we can see how we can assign multiple values in one line of code using the border shorthand property.&lt;/p&gt;

&lt;p&gt;Type and run the code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&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;main&amp;gt;
            &amp;lt;div class="b box"&amp;gt;
               &amp;lt;button&amp;gt;Click Me&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A9zcJkfIUigWYesdy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A9zcJkfIUigWYesdy.png" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, you’ll notice the thin line surrounding the Click Me text, this is what we refer to as a border line. By default the HTML button tag has it turned on. So we will set it to double and add other border sub-properties to make it look nice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS:&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;  .b {
        background-color: rgb(240, 181, 181);
        margin: 10px;
    }

    .box button{
        background-color: blue;
        color: white;
        padding: 1rem 2rem;
        border: 0.5rem double #aff;
        border-radius: 1em;
        box-shadow: 8px 8px 8px 0 rgba(0,0,0, 0.4);
    }

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

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AbFrc4bS-ruEBxuVH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AbFrc4bS-ruEBxuVH.png" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, we added a &lt;strong&gt;border-width&lt;/strong&gt; of &lt;strong&gt;0.5rem&lt;/strong&gt;, a &lt;strong&gt;border-style&lt;/strong&gt; of &lt;strong&gt;double&lt;/strong&gt;, a &lt;strong&gt;border-color&lt;/strong&gt; of hex &lt;strong&gt;#aff&lt;/strong&gt;, and a &lt;strong&gt;border-radius&lt;/strong&gt; of &lt;strong&gt;1rem&lt;/strong&gt;. We also added a box shadow to create an emphasis on the border.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Test your apps on the cloud using our &lt;a href="https://www.lambdatest.com/mobile-emulator-for-app-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;android Emulator for iOS&lt;/a&gt;. Ditch your in-house infrastructure, and gain access to 3000+ browsers in real time.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing CSS Borders
&lt;/h2&gt;

&lt;p&gt;So far, we’ve talked about borders and border sub-properties, their uses, and how we can implement them. In this section, we will see how we can test CSS Borders.&lt;/p&gt;

&lt;p&gt;CSS Borders are essential to web design, as they help define a website’s layout and visual appearance. Testing CSS Borders is important to ensure they appear as intended, function correctly, and prevent user experience issues. In other words, testing CSS Borders ensures visual consistency, accessibility, layout and positioning, and user interaction.&lt;/p&gt;

&lt;p&gt;Testing your CSS Borders with &lt;a href="https://www.lambdatest.com/blog/cloud-testing-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cloud testing&lt;/a&gt; platforms like LambdaTest can help you ensure that your web pages display correctly across multiple browsers and devices, improving user experience and enhancing the overall quality of your website or application.&lt;/p&gt;

&lt;p&gt;LambdaTest is a cloud-based testing platform that allows you to test your website or application on a wide range of browsers and devices, including &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;real device cloud&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android Emulators&lt;/a&gt;, and &lt;a href="https://www.lambdatest.com/ios-simulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;iOS Simulators&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With the LambdaTest Real Time Testing feature, you can quickly and easily identify any issues related to your CSS Borders and address them before they impact the user experience. This saves you time and effort in &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;manually testing&lt;/a&gt; your website on multiple devices and browsers and ensures that your web pages look consistent and professional across all platforms.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hJ-eP8TcGuY"&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" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;emulator online&lt;/a&gt; from LambdaTest allows you to seamlessly test your mobile applications, websites, and web apps on mobile browsers and mobile devices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to test CSS Borders on the cloud?
&lt;/h2&gt;

&lt;p&gt;The code of our created button has already been uploaded on CodePen.&lt;/p&gt;

&lt;p&gt;To get started with &lt;strong&gt;Real Time Testing&lt;/strong&gt; with LambdaTest, follow these steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Sign up for free&lt;/a&gt; and log in to your LambdaTest account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A dialog box should pop up. Click &lt;strong&gt;Realtime Testing&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ADfUAxOd_sjRQm327.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ADfUAxOd_sjRQm327.png" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- This should open up the LambdaTest Real Time Browser Testing Dashboard, where you can start testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2APScsbf0LE26ckkud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2APScsbf0LE26ckkud.png" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Choose the browser you would like to test on (in our case, we’ll go with &lt;strong&gt;Chrome&lt;/strong&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the version, and we’ll choose version &lt;strong&gt;103&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the OS you like to test on. In this case, we’ll choose &lt;strong&gt;Windows 10&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select a screen resolution. In this case, we’ll go with &lt;strong&gt;1280 x 720&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the provided field, paste the website URL you’d like to run the test on. In this case, we’ll paste the URL from the CodePen we created earlier.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ApfXhOj7cvENFqiuv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ApfXhOj7cvENFqiuv.png" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the &lt;strong&gt;START&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AAbj7VbB9FVUFqURk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AAbj7VbB9FVUFqURk.png" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see a loading screen; wait to let it load.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AdSuqxEJo3APgv1Ha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AdSuqxEJo3APgv1Ha.png" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will open the Real Time Browser Viewer hosted on the cloud running a real operating system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2474%2F0%2AAE-CwuaZRDjnbgRE.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2474%2F0%2AAE-CwuaZRDjnbgRE.png" width="800" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where you can perform real time testing. This console lets you change resolutions, debug our website and share a screenshot with your teammates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Automated &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=mar02_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Functional Testing&lt;/a&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;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;You have learned &lt;strong&gt;how to create and style borders using CSS&lt;/strong&gt;. We covered the following border properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Border-width, Border-styles, Border-colors, Border-radius, Border-image&lt;/strong&gt;, and their shorthand &lt;strong&gt;border&lt;/strong&gt; properties.&lt;/p&gt;

&lt;p&gt;Thanks for taking the time to read this blog on CSS Borders to completion. Feel free to ask questions. I’ll gladly reply. You can find me on Twitter and other social media @ocxigin.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cheers
&lt;/h1&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Complete Guide to Document Object Model</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Wed, 25 Jan 2023 00:03:08 +0000</pubDate>
      <link>https://forem.com/testmuai/a-complete-guide-to-document-object-model-1j7c</link>
      <guid>https://forem.com/testmuai/a-complete-guide-to-document-object-model-1j7c</guid>
      <description>&lt;p&gt;The Document Object Model, abbreviated as the DOM, refers to the Virtual Document, which is modeled as a document on the web. Every website has pages that are called HTML documents.&lt;/p&gt;

&lt;p&gt;These documents are represented on the webpage as nodes and objects. When parsed into a web browser such as Chrome, Firefox, Safari, and Opera-Mini, to mention a few helps display information. All information on the web page or document is contents or text, like placeholders on the node in the Document Object Model tree. This Document Object Model tree refers to the structure of the document.&lt;/p&gt;

&lt;p&gt;Ever since the invention of the Internet and its widespread adoption, there has been the need to have a virtual representation of physical things on the web.&lt;/p&gt;

&lt;p&gt;The Physical documents used today in various offices, organizations, and every other corporate environment have been a big part of this. That is the need for a document that properly displays information on the web. However, for this to be possible, the document has to be a model of a physical document and, at the same time, render properly on the web (Web Browsers).&lt;/p&gt;

&lt;p&gt;This document is a text file written in HTML (HyperText Markup Language). It contains Hyperlinks that point to other web pages and also within the same documents. Multimedia files such as Video, Audio, and other Graphic Content can also be embedded within the document. Understanding How the Document Object Model works is a very crucial part of web development.&lt;/p&gt;

&lt;p&gt;In this tutorial on Document Object Model, you will learn everything you need to know to get started with the Document Object Model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: 30 Top &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Automation Testing Tools&lt;/a&gt; In 2022&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Document Object Model (DOM)?
&lt;/h2&gt;

&lt;p&gt;The Document Object Model is a programming interface that comprises web pages (nodes) that is HTML tags such as &amp;lt; html &amp;gt;, &amp;lt; meta &amp;gt;, &amp;lt; title &amp;gt;, &amp;lt; body &amp;gt;, &amp;lt; footer &amp;gt; , &amp;lt; dv &amp;gt;, semantic and non-semantic tags and other nodes objects. The Document Object Model, which is a W3 standard, represents web pages as a tree-like structure of nodes, known as documents.&lt;/p&gt;

&lt;p&gt;The Document Object Model allows web developers to manipulate, style, and structure node objects (HTML documents). For example, web elements are manipulated dynamically with JavaScript to add dynamic content and interactivity to the web page, while CSS is used to add aesthetics. This is referred to as styling to the web page.&lt;/p&gt;

&lt;p&gt;Furthermore, the Document Object Model can also be used with other programming languages such as C#, Ruby, Python, Java, and PHP. However, on the front end, JavaScript and CSS are mostly used as these are the languages of the browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AvIs-fdVbvf59gra5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AvIs-fdVbvf59gra5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Automation Testing Platform&lt;/a&gt;- Accelerate your release velocity with blazing fast test automation on cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The DOM Structure or the DOM TREE
&lt;/h2&gt;

&lt;p&gt;The DOM exists in a hierarchical tree-like structure, where each web element that makes up the document can be thought of as a node, that is, the element tags, the attribute assigned to the element, the comment, the text content, and the document as well is also a node.&lt;/p&gt;

&lt;p&gt;The document object is the root object and can be found within the window’s object. The window’s object defines the document object and how it is rendered or loaded within the webpage.&lt;/p&gt;

&lt;p&gt;The document object has properties and methods that can manipulate contents or element nodes on the page.&lt;/p&gt;

&lt;p&gt;The diagram below gives a simple illustration of what the tree-like structure looks like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AsmSmf8LEJynov64N.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AsmSmf8LEJynov64N.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the Document Object Model structure shown above, you will notice how each element directly connects to other elements; this is known as a hierarchy. This hierarchy is important as this determines how elements are laid out and how they can be accessed with JavaScript and CSS.&lt;/p&gt;

&lt;p&gt;Look at how this hierarchy is laid out in an HTML document.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
      &amp;lt;html&amp;gt;
      &amp;lt;head&amp;gt;
        &amp;lt;meta charset="utf-8"&amp;gt;
        &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
        &amp;lt;title&amp;gt;This is an HTML document&amp;lt;/title&amp;gt;
        &amp;lt;link rel="stylesheet" type="text/css" href="style.css"&amp;gt;
      &amp;lt;/head&amp;gt;
      &amp;lt;body&amp;gt;
        &amp;lt;main&amp;gt;
          &amp;lt;!-- This is the website Navigation --&amp;gt;
          &amp;lt;header&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;SERVICES&amp;lt;/li&amp;gt;
                &amp;lt;li&amp;gt;ABOUT&amp;lt;/li&amp;gt;
              &amp;lt;/ul&amp;gt;
            &amp;lt;/nav&amp;gt;
          &amp;lt;/header&amp;gt;

          &amp;lt;section&amp;gt;
            &amp;lt;h1&amp;gt;The Document Object Model&amp;lt;/h1&amp;gt;
            &amp;lt;p&amp;gt;

      The DOM gives web developers the flexibility to be able to manipulate, style and structure element nodes (HTML elements). For Example web elements are manipulated dynamically with JavaScript to be able to add dynamic content and interactivity to the web page while CSS is used to add aesthetics, this is referred to as styling to the web page.

      Furthermore the DOM can also be used with other programming languages such as, C# (SEE SHARP), Ruby, Python, Java and PHP. However on the frontend JavaScript and CSS are mostly used as these are the languages of the browser.

            &amp;lt;/p&amp;gt;
          &amp;lt;/section&amp;gt;
        &amp;lt;/main&amp;gt;
      &amp;lt;/body&amp;gt;
      &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Now that we have the HTML structure laid out, let’s break down how the hierarchy works.&lt;/p&gt;

&lt;p&gt;From the code sample above, the HTML Document contains different types of HTML tags. Out of all these tags, we have the &amp;lt; html &amp;gt; tag at the top level, followed by the &amp;lt; head &amp;gt; tag. Inside the &amp;lt; head &amp;gt; tag, we have the &amp;lt; meta &amp;gt;,&amp;lt; title &amp;gt;, and &amp;lt; link &amp;gt; tags, respectively. Below the &amp;lt; head &amp;gt; tag, we have the &amp;lt; body &amp;gt; tag.&lt;/p&gt;

&lt;p&gt;The &amp;lt; body &amp;gt; contains all the necessary tags responsible for displaying all the contents on the webpage. The &amp;lt; body &amp;gt; tag, as you can see, includes a &amp;lt; main &amp;gt; tag, a &amp;lt; header &amp;gt; tag, a &amp;lt; nav &amp;gt; tag, &amp;lt; ul &amp;gt; tag, and a &amp;lt; li &amp;gt; tag. Furthermore, below the &amp;lt; header &amp;gt; tag is the &amp;lt; section &amp;gt; tag, and inside the &amp;lt; section &amp;gt; tag are the &amp;lt; h1 &amp;gt; and &amp;lt; p &amp;gt; tags, respectively.&lt;/p&gt;

&lt;p&gt;Please take note when a tag is placed inside another tag. This is referred to as nesting. So we can simply say that the &amp;lt; header &amp;gt; tag is nested inside the &amp;lt; main &amp;gt; tag, while the &amp;lt; main &amp;gt; is nested inside the &amp;lt; body &amp;gt; tag.&lt;/p&gt;

&lt;p&gt;Nesting affects how elements are accessed with JavaScript. For instance, we can create a new element tag from our JavaScript file.&lt;/p&gt;

&lt;p&gt;To do this, we will create the element tag, target the parent element, and then append the new element as a child element.&lt;/p&gt;

&lt;p&gt;The image below explains this better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2At__zopy58e60GSSX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2At__zopy58e60GSSX.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the image above, you will notice some elements appear at the top level, and other elements are placed inside them. You can use this to explain the hierarchical relationship as follows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root node
&lt;/h2&gt;

&lt;p&gt;This refers to the topmost element in the Document Object Model tree. For example, in this case, the &amp;lt; HTML &amp;gt; tag is the root tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parent node
&lt;/h2&gt;

&lt;p&gt;This refers to the element directly at the top of another element. For example, the &amp;lt; body &amp;gt; tag is parent to the &amp;lt; main &amp;gt; tag, as the &amp;lt; body &amp;gt; tag is placed directly above the &amp;lt; main &amp;gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Child node
&lt;/h2&gt;

&lt;p&gt;This refers to the element directly below another element. For example, the &amp;lt; main &amp;gt; tag is a child element to the &amp;lt; body &amp;gt; tag because it is placed directly below the &amp;lt; body &amp;gt; element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online Automation Testing Platform- Accelerate your release velocity with blazing fast &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation cloud&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Grand-child node
&lt;/h2&gt;

&lt;p&gt;This refers to any element that is below the child element. For example, the &amp;lt; header &amp;gt; is below the &amp;lt; main &amp;gt;, which is a child of the &amp;lt; body &amp;gt; tag. This makes the &amp;lt; header &amp;gt; tag a grand-child of the &amp;lt; body &amp;gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Siblings
&lt;/h2&gt;

&lt;p&gt;This refers to any two or more elements that share the same parent and are on the same level. For example, the &amp;lt; header &amp;gt; and the &amp;lt; section &amp;gt; tags share the parent, the &amp;lt; main &amp;gt; tag. Hence they can be referred to as siblings in the document tree.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ancestor node
&lt;/h2&gt;

&lt;p&gt;This refers to the element that all other elements are nested in. For example, in this case, the &amp;lt; html &amp;gt; can be referred to as the ancestor to other elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Descendants
&lt;/h2&gt;

&lt;p&gt;The parent, children, siblings, and grand-children are all referred to as descendants of the root element. For example, every document tree element is a descendant of the &amp;lt; html &amp;gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Leaf node
&lt;/h2&gt;

&lt;p&gt;The last element or node in document three that does not have a child. A leaf node can also be described as the end of a branch in a Document Object Model tree.&lt;/p&gt;

&lt;p&gt;The image below explains the above concept better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AtZhU3vmidiRUvZ_n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AtZhU3vmidiRUvZ_n.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Web Testing&lt;/a&gt; Tutorial: Comprehensive Guide With Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessing the DOM Interface
&lt;/h2&gt;

&lt;p&gt;The DOM is an interface that provides us with object nodes, and there are lots of built-in properties/methods we can use to access and manipulate the contents in the Document Object Model tree in JavaScript.&lt;/p&gt;

&lt;p&gt;Using the HTML &amp;lt; script &amp;gt; tag, we can embed JavaScript code within the HTML file or link it to an external file and then use methods available in JavaScript to access and manipulate the Document Object Model.&lt;/p&gt;

&lt;p&gt;This is necessary; for instance, we can create and validate a form field that lets users sign up for our newsletter, and we can also make web elements interactive when users over-hover them.&lt;/p&gt;

&lt;p&gt;The next section will explain the methods and properties we can use to make changes to the Document Object Model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Testing&lt;/a&gt; Automation Cloud: Test on Selenium Grid Cloud of 3000+ Desktop &amp;amp; Mobile Browsers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Document Instance Properties
&lt;/h2&gt;

&lt;p&gt;Document Instance Properties are used to capture information about the state of an object at a given point in time.&lt;/p&gt;

&lt;h3&gt;
  
  
  classList
&lt;/h3&gt;

&lt;p&gt;The element.classList instance property returns a class attribute of a live DOMTokenList collection. The DOMTokenList instance methods are required to manipulate or make changes when using the classList instance properties.&lt;/p&gt;

&lt;p&gt;The instance methods for the classList instance property are as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;add()&lt;/strong&gt;: used to add one or more classes to the class attributes of an element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;remove()&lt;/strong&gt;: used to remove one or more classes from the class attributes of an element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;replace()&lt;/strong&gt;: used to replace a given class with a new class within the class attributes of an element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;toggle()&lt;/strong&gt;: used to toggle a given class within a class attribute of an element. That is when you make use of the toggle method. It removes the class you assign to the element from the class attribute if the class exists and replaces it if the class does not exist within the element.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take the example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;h1&amp;gt;This is classList property&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;Click the boxes to change color&amp;lt;/p&amp;gt;

        &amp;lt;main&amp;gt;
          &amp;lt;div class="default-Color" id="addOne"&amp;gt;This is a add()     method&amp;lt;/div&amp;gt;
          &amp;lt;div class="default-Color" id="addTwo"&amp;gt;This is a remove() method&amp;lt;/div&amp;gt;
          &amp;lt;div class="default-Color" id="addThree"&amp;gt;This is a replace() method&amp;lt;/div&amp;gt;
          &amp;lt;div class="default-Color" id="addFour"&amp;gt;This is a toggle() method&amp;lt;/div&amp;gt;
        &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 &amp;lt;h1&amp;gt;This is classList property&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Click the boxes to change color&amp;lt;/p&amp;gt;

      &amp;lt;main&amp;gt;
        &amp;lt;div class="default-Color" id="addOne"&amp;gt;This is a add() method&amp;lt;/div&amp;gt;
        &amp;lt;div class="default-Color" id="addTwo"&amp;gt;This is a remove() method&amp;lt;/div&amp;gt;
        &amp;lt;div class="default-Color" id="addThree"&amp;gt;This is a replace() method&amp;lt;/div&amp;gt;
        &amp;lt;div class="default-Color" id="addFour"&amp;gt;This is a toggle() method&amp;lt;/div&amp;gt;
      &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    main {
        display: flex;
      }

      div {
        width: 150px;
        height: 80px;
        margin: 0.4em;
        border: 2px solid #000000;
      }

      .default-Color{
        background: red;
      }

      .green {
        background: green;
      }

      .purple {
        background: purple;
      }

      .blue {
        background: blue;
      }

      .orange {
        background: orange;
      }

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



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //Variable
      const addColor = document.querySelector('#addOne');
      const removeColor = document.querySelector('#addTwo');
      const replaceColor = document.querySelector('#addThree');
      const toggleColor = document.querySelector('#addFour');

      // function

      //add() methods
      function addMyColorGreen(){
        addColor.classList.add('green')
        console.log(addColor);

      }


      //remove() methods
      function addMyColorRed(){
        removeColor.classList.remove('default-Color')
        console.log(removeColor);

      }


      //replace() methods
      function addMyColorBlue(){
        replaceColor.classList.replace('default-Color', 'blue')
        console.log(replaceColor);

      }


      //toggle() methods
      function addMyColorOrange(){
        toggleColor.classList.toggle('orange')
        console.log(toggleColor);
      }


      // EventLinsterners
      addColor.addEventListener('click', addMyColorGreen);
      removeColor.addEventListener('click', addMyColorRed);
      replaceColor.addEventListener('click', addMyColorBlue);
      toggleColor.addEventListener('click', addMyColorOrange);

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



&lt;p&gt;From the HTML code example, we have an &amp;lt; main &amp;gt; as the parent tag, and we nested four &amp;lt; div &amp;gt; tags inside the &amp;lt; main &amp;gt; tag.&lt;/p&gt;

&lt;p&gt;Each &amp;lt; div &amp;gt; tag is assigned a class of default-Color and an id of addOne, addTwo, addThree, and addFour, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
      main {
          display: flex;
        }

        div {
          width: 150px;
          height: 80px;
          margin: 0.4em;
          border: 2px solid #000000;
        }

        .default-Color{
          background: red;
        }

        .green {
          background: green;
        }

        .purple {
          background: purple;
        }

        .blue {
          background: blue;
        }

        .orange {
          background: orange;
        }

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



&lt;p&gt;While from the CSS code sample, we set a &lt;em&gt;display&lt;/em&gt; of &lt;em&gt;flex&lt;/em&gt; to &amp;lt; main &amp;gt; tag, the parent element in this case and we targeted the &amp;lt; div &amp;gt; tag, we set the width and height to 150px and 80px respectively, &lt;em&gt;margin 0.4em&lt;/em&gt; across and a border of &lt;em&gt;2px solid&lt;/em&gt; and #000000 (black).&lt;/p&gt;

&lt;p&gt;Furthermore, we set the &lt;em&gt;default&lt;/em&gt;-Color to red, so each box is red by default, and we created four extra utility classes waiting to be used.&lt;/p&gt;

&lt;p&gt;We will see how we can use JavaScript to change the elements using these classes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Variable
        const addColor = document.querySelector('#addOne');
        const removeColor = document.querySelector('#addTwo');
        const replaceColor = document.querySelector('#addThree');
        const toggleColor = document.querySelector('#addFour');

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



&lt;p&gt;First, we use the &lt;em&gt;querySelector()&lt;/em&gt; method to get the element and then assign them to a variable, as you can see. We create four variables named &lt;em&gt;addColor, removeColor, replaceColor, and toggleColor&lt;/em&gt;, respectively.&lt;/p&gt;

&lt;p&gt;Variables are just like containers; they help us store values so we can access them or reuse them later in our code. In this case, we want to be able to make changes to our element, so we assign each element to a variable, and we use the &lt;em&gt;querySelector()&lt;/em&gt; method to reference the element id attribute.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // function

        //add() methods
        function addMyColorGreen(){
          addColor.classList.add('green')
          console.log(addColor);
        }

        //remove() methods
        function addMyColorRed(){
          removeColor.classList.remove('default-Color')
          console.log(removeColor);
        }

        //replace() methods
        function addMyColorBlue(){
          replaceColor.classList.replace('default-Color', 'blue')
          console.log(replaceColor);
        }

        //toggle() methods
        function addMyColorOrange(){
          toggleColor.classList.toggle('orange')
          console.log(toggleColor);
        }
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;In JavaScript, functions allow us to perform takes or calculations that can be reused within our code. Also, we can make changes to a given element based on the values or tasks created within the function.&lt;/p&gt;

&lt;p&gt;In this case, we created a function with the name &lt;em&gt;addMyColorGreen()&lt;/em&gt;. Inside this function, we called the addColor variable, which we created earlier, and then assigned the classList instance property to target the class attribute of the element.&lt;/p&gt;

&lt;p&gt;This returns a DOMTokenList, and we use the &lt;em&gt;add()&lt;/em&gt; instance method of the &lt;em&gt;DOMTokenList&lt;/em&gt; to add a CSS class of green from our stylesheet to the element attribute.&lt;/p&gt;

&lt;p&gt;When done, any value associated with the CSS class upon assignment is parsed to the element.&lt;/p&gt;

&lt;p&gt;In this case, we have a value of green parsed to the element as a background color.&lt;/p&gt;

&lt;p&gt;Furthermore, you will have noticed that we also have a &lt;em&gt;console.log()&lt;/em&gt; method with a value of addColor parsed right inside the function we just created. This will log the element to the console to see if the class we have assigned is parsed in as expected.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
      // EventLinsterners
        addColor.addEventListener('click', addMyColorGreen);
        removeColor.addEventListener('click', addMyColorRed);
        replaceColor.addEventListener('click', addMyColorBlue);
        toggleColor.addEventListener('click', addMyColorOrange);

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



&lt;p&gt;Writing functions are great, but they can be useless if they are not told when to behave. That is when the function should be called. In this case, we have event listeners.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/java-event-listeners/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Event Listeners&lt;/a&gt;, programmatically written as &lt;em&gt;addEventListner()&lt;/em&gt;, is a JavaScript Event method that allows you to add an event to an element. When the event is triggered on the webpage, it takes in an event and a function you want to respond to. In this case, we assign a value to the click event. We want the function to respond when we click the object referenced on the &lt;em&gt;addEventListener()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;The object we are referencing is the &lt;em&gt;addColor&lt;/em&gt; variable. When the element with the &lt;em&gt;addColor&lt;/em&gt; variable is clicked on, we want the background color to change and long the element to the browser console.&lt;/p&gt;

&lt;p&gt;Type the code above and run to see the output below, but remember to open up for dev tools (inspect).&lt;/p&gt;

&lt;p&gt;To do this, simply right-click on the webpage and then click Inspect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A1fkrpR7MbpcSkDyd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A1fkrpR7MbpcSkDyd.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AtNRVaoCXnQntviho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AtNRVaoCXnQntviho.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first box adds a green color to the background.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second box removes the red background and leaves it with a no-fill color with a border of black.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The third box replaces the red with a blue color.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The last box toggles between the red and orange color.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can click the last box multiple times to see how the color changes continuously.&lt;/p&gt;

&lt;h3&gt;
  
  
  className
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.className&lt;/em&gt; instance property sets or returns a class attribute of a given element.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;className&lt;/em&gt; property, like the classList, does not require a method to function; you can simply assign values to it directly.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main&amp;gt;This is a className property&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;We have a simple &amp;lt; main &amp;gt; tag with a display of text content. We need to parse a class attribute to the &amp;lt; main &amp;gt; tag using the className instance property.&lt;/p&gt;

&lt;p&gt;Type and run the JavaScript below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      const getMain = document.querySelector('main');

      getMain.className = 'set-class';

      console.log(getMain)
&lt;/code&gt;&lt;/pre&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2Aqhp4lDsig0_RhKaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2Aqhp4lDsig0_RhKaf.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   &amp;lt;main&amp;gt;This is a className property&amp;lt;/main&amp;gt;

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



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const getMain = document.querySelector('main');

    getMain.className = 'set-class';

    console.log(getMain)
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;See the display of the newly created class attribute in the console above.&lt;/p&gt;

&lt;h3&gt;
  
  
  innerHTML
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.innerHTML&lt;/em&gt; instance property sets or returns the HTML content of an element. This is useful when we want to parse content together with the HTML tags into the Document Object Model.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main id="mainOne"&amp;gt;&amp;lt;/main&amp;gt;
      &amp;lt;main id="mainTwo"&amp;gt;&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;We have two main tags, each with an id attribute of &lt;em&gt;mainOne&lt;/em&gt; and &lt;em&gt;mainTwo&lt;/em&gt;, respectively.&lt;/p&gt;

&lt;p&gt;Now, let’s see how we can make some modifications to JavaScript. Type and run the JavaScript code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; //Variables
      const mainTag = document.querySelector('#mainOne');
      const mainTagTwo = document.querySelector('#mainTwo');

      const parseContent = '&amp;lt;p&amp;gt;This is main one&amp;lt;/p&amp;gt;';
      const parseContentTwo = 'This is main Two';

      mainTag.innerHTML = parseContent;
      mainTagTwo.innerHTML = parseContentTwo;

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



&lt;p&gt;From the JavaScript code above, &lt;em&gt;parseContent&lt;/em&gt; is assigned a string value wrapped in HTML &amp;lt; p &amp;gt; tags, while &lt;em&gt;parseContentTwo&lt;/em&gt; is assigned a string value with text content only.&lt;/p&gt;

&lt;p&gt;Then we target the &lt;em&gt;mainOne&lt;/em&gt; and &lt;em&gt;mainTwo&lt;/em&gt; elements. Using the &lt;em&gt;innerTHML&lt;/em&gt; property, we access the properties of both elements and then parse in &lt;em&gt;parseContent&lt;/em&gt; and &lt;em&gt;parseContentTwo&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We do this to parse the content to empty &amp;lt; main &amp;gt; tags. Now let’s take a look at how this works on the browser.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2594%2F0%2AWpns58E6ItBZGodr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2594%2F0%2AWpns58E6ItBZGodr.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main id="mainOne"&amp;gt;&amp;lt;/main&amp;gt;
    &amp;lt;main id="mainTwo"&amp;gt;&amp;lt;/main&amp;gt;

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



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Variables
    const mainTag = document.querySelector('#mainOne');
    const mainTagTwo = document.querySelector('#mainTwo');

    const parseContent = '&amp;lt;p&amp;gt;This is main one&amp;lt;/p&amp;gt;';
    const parseContentTwo = 'This is main Two';

    mainTag.innerHTML = parseContent;
    mainTagTwo.innerHTML = parseContentTwo;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;From the browser output, we have the two content displays on the browser, but if we inspect the browser and take a look at the devtools, you will find that the &lt;em&gt;parseContent&lt;/em&gt; variable has a &amp;lt; p &amp;gt; tag inserted inside the &lt;em&gt;mainOne&lt;/em&gt; element while &lt;em&gt;parseContentTwo&lt;/em&gt; variable only inserts the text content.&lt;/p&gt;

&lt;p&gt;Also, the &lt;em&gt;mainOne&lt;/em&gt; element displays the element parsed like &lt;em&gt;mainTwo&lt;/em&gt; without displaying the &amp;lt; p &amp;gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  outerHTML
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.outerHTML&lt;/em&gt; instance property sets and replaces the HTML tags and the content of a given element. This is useful when we want to parse new HTML tags to replace a given HTML tag and its content within the DOM.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main id="mainOne"&amp;gt;
        &amp;lt;ul&amp;gt;
          &amp;lt;li&amp;gt;This is a list element&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/main&amp;gt;

      &amp;lt;main id="mainTwo"&amp;gt;This is outerHTML&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;From the HTML code example above, we decided to add &amp;lt; li &amp;gt; with text content and nest it inside a &amp;lt; ul &amp;gt; tag, this &amp;lt; ul &amp;gt; tag is also nested inside the &amp;lt; main &amp;gt; tag we used earlier. So what we want to do is use the outerHTML instance property to replace the two &amp;lt; main &amp;gt; tags.&lt;/p&gt;

&lt;p&gt;Type and run the JavaScript code below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mainTag = document.querySelector('#mainOne');
      const mainTagTwo = document.querySelector('#mainTwo');

      const parseContent = '&amp;lt;p&amp;gt;This is main one&amp;lt;/p&amp;gt;';
      const parseContentTwo = 'This is main Two';

      mainTag.outerHTML = parseContent;
      mainTagTwo.outerHTML = parseContentTwo;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;From the code example above, we targeted the two main tags, and we used &lt;em&gt;outerHTML&lt;/em&gt; to replace the tags and their content.&lt;/p&gt;

&lt;p&gt;We assign the values we want to use to &lt;em&gt;parseContent&lt;/em&gt; and &lt;em&gt;parseContentTwo&lt;/em&gt;, and each variable is parsed to &lt;em&gt;mainOne&lt;/em&gt; and &lt;em&gt;mainTwo&lt;/em&gt;, respectively, using the outerHTML instance property. Now let’s see how this renders on the browser.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2AqyyW-_rodV5_3K6P.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2AqyyW-_rodV5_3K6P.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main id="mainOne"&amp;gt;
      &amp;lt;ul&amp;gt;
        &amp;lt;li&amp;gt;This is a list element&amp;lt;/li&amp;gt;
      &amp;lt;/ul&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;main id="mainTwo"&amp;gt;This is outerHTML&amp;lt;/main&amp;gt;


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



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mainTag = document.querySelector('#mainOne');
    const mainTagTwo = document.querySelector('#mainTwo');

    const parseContent = '&amp;lt;p&amp;gt;This is main one&amp;lt;/p&amp;gt;';
    const parseContentTwo = 'This is main Two';

    mainTag.outerHTML = parseContent;
    mainTagTwo.outerHTML = parseContentTwo;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;As indicated by the two arrows inside the devtools, the two &amp;lt; main &amp;gt; tags have been replaced completely. The &lt;em&gt;mainOne&lt;/em&gt; element and its descendants (&amp;lt; ul &amp;gt; and &amp;lt; li &amp;gt;) element have been replaced with just a &amp;lt; p &amp;gt; and a text content, while the &lt;em&gt;mainTwo&lt;/em&gt; element is replaced with just text content with no given element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation&lt;/a&gt; Cloud: Test on Selenium Grid Cloud of 3000+ Desktop &amp;amp; Mobile Browsers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  innerText
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.innerText&lt;/em&gt; instance property sets and replaces the content and descendants of a given element. This is useful when you want to parse new content into a given HTML tag.&lt;/p&gt;

&lt;p&gt;Also, note that the innerText will only return text, so if you parse in HTML tags, it will return it as text and print it into the browser.&lt;/p&gt;

&lt;p&gt;If the element you wish to update has a child element or descendants, it will be replaced with a text.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;This is innerText&amp;lt;/h1&amp;gt;

      &amp;lt;main id="mainOne"&amp;gt;
         &amp;lt;p&amp;gt;Happy Coding!&amp;lt;/p&amp;gt;
      &amp;lt;/main&amp;gt;

      &amp;lt;main id="mainTwo"&amp;gt;&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;We have two &amp;lt; main &amp;gt; tags, a &lt;em&gt;mainOne&lt;/em&gt; tag with a &amp;lt; p &amp;gt; tag and text content and an empty &lt;em&gt;mainTwo&lt;/em&gt; tag. Now let’s see how we can change &lt;em&gt;mainOne&lt;/em&gt; and &lt;em&gt;mainTwo&lt;/em&gt; using innerText.&lt;/p&gt;

&lt;p&gt;Type and run the JavaScript code below.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mainOne = document.querySelector('#mainOne');
      const mainTwo = document.querySelector('#mainTwo');

      mainOne.innerText = '&amp;lt;em&amp;gt;Hello World&amp;lt;/em&amp;gt;';
      mainTwo.innerText = 'Hello World';
&lt;/code&gt;&lt;/pre&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F0%2AfB3WMno_t0sdCAPS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F0%2AfB3WMno_t0sdCAPS.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;This is innerText&amp;lt;/h1&amp;gt;

    &amp;lt;main id="mainOne"&amp;gt;
       &amp;lt;p&amp;gt;Happy Coding!&amp;lt;/p&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;main id="mainTwo"&amp;gt;&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mainOne = document.querySelector('#mainOne');
    const mainTwo = document.querySelector('#mainTwo');

    mainOne.innerText = '&amp;lt;em&amp;gt;Hello World&amp;lt;/em&amp;gt;';
    mainTwo.innerText = 'Hello World';
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;From the browser output, we set &lt;em&gt;mainOne&lt;/em&gt; and &lt;em&gt;mainTwo&lt;/em&gt; to display Hello World. The &amp;lt; em &amp;gt; tag we assigned to &lt;em&gt;mainOne&lt;/em&gt; is supposed to make the text italic, but since we parse it through the &lt;em&gt;innerText&lt;/em&gt; property, the text content is parsed as plain text with no italic styling effect.&lt;/p&gt;

&lt;p&gt;And also, the &amp;lt; p &amp;gt; tag with the text of &lt;em&gt;Happy Coding&lt;/em&gt; is completely replaced, while the &lt;em&gt;mainTwo&lt;/em&gt; element we assigned a text of Hello World with no tags enclosing it is printed on the screen.&lt;/p&gt;

&lt;p&gt;Another thing you have to take note of is how this affects the Document Object Model tree. From the devtool view, as you would have noticed, the &amp;lt; p &amp;gt; is completely replaced, and the &lt;em&gt;mainTwo&lt;/em&gt; is updated with a new text.&lt;/p&gt;

&lt;h3&gt;
  
  
  outerText
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.outerText&lt;/em&gt; instance property sets and replaces the HTML tag, its content and descendants within the Document Object Model tree. This is useful when you want to parse new content into a given HTML tag. This will replace the specified tag leaving you with only text content.&lt;/p&gt;

&lt;p&gt;If the element you wish to update has a child element or descendants, it will be replaced with a text. So be sure you are parsing it to the last child on the element node to prevent error.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;strong&amp;gt;HTML:&amp;lt;/strong&amp;gt;

      &amp;lt;h1&amp;gt;This is outerText&amp;lt;/h1&amp;gt;

      &amp;lt;main id="mainOne"&amp;gt;
      &amp;lt;p&amp;gt;Happy Coding!&amp;lt;/p&amp;gt;
      &amp;lt;/main&amp;gt;

      &amp;lt;main id="mainTwo"&amp;gt;&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Just like the previous example from innerText, here we have the same HTML code setup. Now let’s see how we can use the outerText instance property to change the Document Object Model tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const mainOne = document.querySelector('#mainOne');
      const mainTwo = document.querySelector('#mainTwo');

      mainOne.outerText = '&amp;lt;em&amp;gt;Hello World&amp;lt;/em&amp;gt;';
      mainTwo.outerText = 'Hello World';

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



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AK5HaTdXbmqhFgUpn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AK5HaTdXbmqhFgUpn.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;This is outerText&amp;lt;/h1&amp;gt;

    &amp;lt;main id="mainOne"&amp;gt;
    &amp;lt;p&amp;gt;Happy Coding!&amp;lt;/p&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;main id="mainTwo"&amp;gt;&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mainOne = document.querySelector('#mainOne');
    const mainTwo = document.querySelector('#mainTwo');

    mainOne.outerText = '&amp;lt;em&amp;gt;Hello World&amp;lt;/em&amp;gt;';
    mainTwo.outerText = 'Hello World';

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



&lt;p&gt;From the devtool how the two &amp;lt; main &amp;gt; tags have been replaced and the effect it has on the browser output.&lt;/p&gt;

&lt;h3&gt;
  
  
  children
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.children&lt;/em&gt; instance property returns all the child/children of a given element. The children property returns it as a live HTML collection.&lt;/p&gt;

&lt;p&gt;Also, take note that the children instance property only returns element nodes.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;main class="root"&amp;gt;
        &amp;lt;div id="parent"&amp;gt;
          &amp;lt;div id="one"&amp;gt;one&amp;lt;/div&amp;gt;
          &amp;lt;div id="two"&amp;gt;two&amp;lt;/div&amp;gt;
          &amp;lt;div id="two"&amp;gt;three&amp;lt;/div&amp;gt;
          &amp;lt;div id="two"&amp;gt;four&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/main&amp;gt;

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



&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const parentEl = document.querySelector('#parent');

      const returnChildren = parentEl.children;

      console.log(returnChildren)

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



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A8OHIwrwwGklnlH5O.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A8OHIwrwwGklnlH5O.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    &amp;lt;main class="root"&amp;gt;
     &amp;lt;div id="parent"&amp;gt;
      &amp;lt;div id="one"&amp;gt;one&amp;lt;/div&amp;gt;
      &amp;lt;div id="two"&amp;gt;two&amp;lt;/div&amp;gt;
      &amp;lt;div id="two"&amp;gt;three&amp;lt;/div&amp;gt;
      &amp;lt;div id="two"&amp;gt;four&amp;lt;/div&amp;gt;
     &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

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



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    const parentEl = document.querySelector('#parent');

    const returnChildren = parentEl.children;

    console.log(returnChildren)

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



&lt;p&gt;From the console output, the &lt;em&gt;children&lt;/em&gt; instance property returns all the child element of the given parent as a live HTML Collection.&lt;/p&gt;

&lt;h3&gt;
  
  
  firstElementChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.firstElementChild&lt;/em&gt; instance property returns only the first child of a given element If the element you wish to return has no child element, it returns a null.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;main class="root"&amp;gt;
        &amp;lt;ul class="parent"&amp;gt;
          &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getParent = document.querySelector('.parent');

      const getChildOne = getParent.firstElementChild;
      console.log(getChildOne)
&lt;/code&gt;&lt;/pre&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A2eMl2umDauGtz3SJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A2eMl2umDauGtz3SJ.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="root"&amp;gt;
     &amp;lt;ul class="parent"&amp;gt;
      &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;
      &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;
      &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;
      &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;
      &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;
      &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;
     &amp;lt;/ul&amp;gt;
    &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



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

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getParent = document.querySelector('.parent');

    const getChildOne = getParent.firstElementChild;
    console.log(getChildOne)
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;From the console output, notice that we have printed the first child element.&lt;/p&gt;

&lt;h3&gt;
  
  
  lastElementChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.lastElementChild&lt;/em&gt; instance property returns only the last child of a given element. If the element you wish to return has no child element, it returns a null.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main class="root"&amp;gt;
        &amp;lt;ul class="parent"&amp;gt;
          &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;
          &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; const getParent = document.querySelector('.parent');

      const getChildSix = getParent.lastElementChild;


      console.log(getChildSix)
&lt;/code&gt;&lt;/pre&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AnMTeN7zCdT4gP1rZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AnMTeN7zCdT4gP1rZ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
     &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
     &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChildSix = getParent.lastElementChild;


console.log(getChildSix)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, notice that we have the last child element printed out.&lt;/p&gt;
&lt;h3&gt;
  
  
  nextElementSibling
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.nextElementSibling&lt;/em&gt; instance property returns the next element of the same sibling in the Document Object Model level of a given element. If the element you wish to return happens to be the last child element, it returns a &lt;em&gt;null&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
        &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;/ul&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChildOne = getParent.firstElementChild;

  const getSiblings = getChildOne.nextElementSibling; 

  console.log(getSiblings)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3q7lU_o0UfNF4Gx9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3q7lU_o0UfNF4Gx9.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
     &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
     &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChildOne = getParent.firstElementChild;

const getSiblings = getChildOne.nextElementSibling; 

console.log(getSiblings)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, notice that we have the next element sibling printed out.&lt;/p&gt;
&lt;h3&gt;
  
  
  previousElementSibling
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.previousElementSibling&lt;/em&gt; instance property returns the previous element of the same sibling in the Document Object Model level of a given element. If the element you wish to return happens to be the first child element, it returns a &lt;em&gt;null&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Take the code example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
        &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;/ul&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChildSix = getParent.lastElementChild;

  const getSiblings = getChildSix.previousElementSibling; 

  console.log(getSiblings)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A5gsgAQbLyzc9H4Mp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A5gsgAQbLyzc9H4Mp.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
     &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
     &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChildSix = getParent.lastElementChild;

const getSiblings = getChildSix.previousElementSibling; 

console.log(getSiblings)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, notice that we have the previous element sibling printed out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium online&lt;/a&gt; Test Automation Cloud: Test on Selenium Grid Cloud of 3000+ Desktop &amp;amp; Mobile Browsers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Document Methods
&lt;/h2&gt;

&lt;p&gt;In this section of this blog on the Document Object Model, I will try to describe some of the most useful methods available in DOM&lt;/p&gt;
&lt;h3&gt;
  
  
  QuerySelector
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;querySelector()&lt;/em&gt; document method returns the first element that matches the specified CSS selector passed in within the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
document.querySelector(CSS selectors)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the simple code example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

querySelector using: class
      
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div id="my-id"&amp;gt;querySelector using: id&amp;lt;/div&amp;gt;

  &amp;lt;section&amp;gt;querySelector using: tag Name&amp;lt;/section&amp;gt;

  &amp;lt;input type="text" name="css-attribute" value="my input tag"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
      //Accessing web element by class Name&lt;br&gt;
      const myClass = document.querySelector('.my-class');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //Accessing web element by id Name
  const myId = document.querySelector('#myId');

  //Accessing web element with by Tag Name
  const section = document.querySelector('section');

  //Accessing web element with class attribute
  const myInput = document.querySelector('input[type]');
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

querySelector using: class
    
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="my-id"&amp;gt;querySelector using: id&amp;lt;/div&amp;gt;

&amp;lt;section&amp;gt;querySelector using: tag Name&amp;lt;/section&amp;gt;

&amp;lt;input type="text" name="css-attribute" value="my input tag"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Accessing web element by class Name&lt;br&gt;
    const myClass = document.querySelector('.my-class');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Accessing web element by id Name
const myId = document.querySelector('#myId');

//Accessing web element with by Tag Name
const section = document.querySelector('section');

//Accessing web element with class attribute
const myInput = document.querySelector('input[type]');
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There are different ways to select elements using &lt;em&gt;querySelector()&lt;/em&gt; methods. As long as the value assigned within the parenthesis is a valid way of selecting elements in CSS, the &lt;em&gt;querySelector()&lt;/em&gt; method will return the element.&lt;/p&gt;
&lt;h3&gt;
  
  
  QuerySelectorAll
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;querySelector()&lt;/em&gt; document method returns a static nodeList (Not Live) of all elements that match the specified CSS selector passed within the DOM tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
document.querySelectorAll(CSS selectors)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the simple code example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

querySelector using: class
      
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div id="my-id"&amp;gt;querySelector using: id&amp;lt;/div&amp;gt;

  &amp;lt;section&amp;gt;querySelector using: tag Name&amp;lt;/section&amp;gt;

  &amp;lt;input type="text" name="css-attribute" value="my input tag"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
    //Accessing all web element with just one method&lt;br&gt;
      const selectAll = document.querySelectorAll('.my-class, #my-id, section, input[type]');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  console.log(selectAll)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AW7_Hf_uqi4Dv4vO3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AW7_Hf_uqi4Dv4vO3.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

querySelector using: class
    
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="my-id"&amp;gt;querySelector using: id&amp;lt;/div&amp;gt;

&amp;lt;section&amp;gt;querySelector using: tag Name&amp;lt;/section&amp;gt;

&amp;lt;input type="text" name="css-attribute" value="my input tag"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Accessing all web element with just one method&lt;br&gt;
    const selectAll = document.querySelectorAll('.my-class, #my-id, section, input[type]');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(selectAll)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, notice how all the elements we selected are all listed out as a NodeList.&lt;/p&gt;
&lt;h3&gt;
  
  
  getElementById
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;document.getElementById()&lt;/em&gt; returns an element object with a unique id attribute of a given element from the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 document.getElementById(“idAtrribute”)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the simple code example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;div id=”myId”&amp;gt;qetElementByID using: Id&amp;lt;/div&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
   //Accessing web element with an ID attribute&lt;br&gt;
      const myId = document.getElementById('myId');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  console.log(myId)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmJRIeTiUESBFlP8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmJRIeTiUESBFlP8f.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
    &amp;lt;div id="myId"&amp;gt;qetElementByID using: Id&amp;lt;/div&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
    //Accessing web element with an ID attribute&lt;br&gt;
    const myId = document.getElementById('myId');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(myId)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice how the &lt;em&gt;getElementById&lt;/em&gt; method is used to return the specified element.&lt;/p&gt;
&lt;h3&gt;
  
  
  getElementsByTagName
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;document.getElementsByTagName()&lt;/em&gt; returns an HTML Collection object with a specific tag name from the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 document.getElementsByTagName(“h1”)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main&amp;gt;&lt;br&gt;
          &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
          &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
          &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
          &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Accessing web element by it tag name&lt;br&gt;
      const myTagNames = document.getElementsByTagName('div');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  console.log(myTagNames)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A6Bshrhzz_v_fNI7W.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A6Bshrhzz_v_fNI7W.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main&amp;gt;&lt;br&gt;
        &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div&amp;gt;qetElementByTagName using: Tag Name&amp;lt;/div&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Accessing web element by it tag name&lt;br&gt;
    const myTagNames = document.getElementsByTagName('div');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(myTagNames)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice how the &lt;em&gt;getElementsByTagName&lt;/em&gt; method is used to return an HTML Collection object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright automated testing&lt;/a&gt; Tutorial: Getting Started With Playwright Framework&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  getElementsByClassName
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;document.getElementsByClassName()&lt;/em&gt; returns a collection of array-like objects with a specific class name from the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
    document.getElementsByNameClass(“class-name”)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main&amp;gt;&lt;br&gt;
        &amp;lt;div class="one"&amp;gt;qetElementsByTagName using: Class Name&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div class="one"&amp;gt;qetElementsByTagName using: Class Name&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div class="one"&amp;gt;qetElementsByTagName using: Class Name&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div class="one"&amp;gt;qetElementsByTagName using: Class Name&amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Accessing web element by it class name&lt;br&gt;
      const myClassName = document.getElementsByClassName('one');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  console.log(myClassName)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3WxuhvdDapElEWcd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3WxuhvdDapElEWcd.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 &lt;br&gt;
      qetElementsByTagName using: Class Name&lt;br&gt;
      qetElementsByTagName using: Class Name&lt;br&gt;
      qetElementsByTagName using: Class Name&lt;br&gt;
      qetElementsByTagName using: Class Name&lt;br&gt;
    &lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Accessing web element by it class name&lt;br&gt;
    const myClassName = document.getElementsByClassName('one');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(myClassName)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice how the &lt;em&gt;getElementsByClassName&lt;/em&gt; method is used to return an HTML collection of array-like objects.&lt;/p&gt;
&lt;h3&gt;
  
  
  createElement
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;document.createElement()&lt;/em&gt; creates a new HtmlElement referenced by the value passed in. The value is passed as a string in lowercase later in between double or single quote and a valid tag name should be used.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
    document.createElement(“div”)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Creating a new element using createElement methods&lt;br&gt;
      const newEl = document.createElement('p');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  newEl.innerText = 'This is a new paragraph';

  console.log(newEl);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmqoOAqcRX2ngJqV_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AmqoOAqcRX2ngJqV_.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//Creating a new element using createElement methods&lt;br&gt;
    const newEl = document.createElement('p');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;newEl.innerText = 'This is a new paragraph';

console.log(newEl);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the code sample above, we created a new element and parsed in a string of text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Cross Browser Testing Cloud - Browser &amp;amp; app testing cloud to perform both exploratory and automated &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;testing web&lt;/a&gt; across 3000+ different browsers, real devices and operating systems.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Append
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.append()&lt;/em&gt; is used to add a new element or text content to the last child of an element child. If you append an element/text to a parent tag, the element or text you appended is added to the last child of that element.&lt;/p&gt;

&lt;p&gt;Take note that the &lt;em&gt;append()&lt;/em&gt; method differs from the &lt;em&gt;appendChild()&lt;/em&gt; of the nodeList method. While the &lt;em&gt;append()&lt;/em&gt; method allows you to append multiple elements at once, the &lt;em&gt;appendChild()&lt;/em&gt; can only append one. With the &lt;em&gt;append()&lt;/em&gt; method, a text node can be appended, while &lt;em&gt;appendChild()&lt;/em&gt; only appends an Element node.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
// you can pass in single value&lt;br&gt;
      element.append("Element")&lt;br&gt;
      //you can pass in multiple values&lt;br&gt;
      element.append("string", "string")&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 &lt;br&gt;
        &lt;br&gt;
          one&lt;br&gt;
          two&lt;br&gt;
        &lt;br&gt;
      &lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the HTML code sample we have a &amp;lt; div &amp;gt; tag with an id of parent. Inside this &amp;lt; div &amp;gt; tag, we have two more nested &amp;lt; div &amp;gt; tags with the text content of one and two, respectively. We will add two more &amp;lt; div &amp;gt; tags to the children element.&lt;/p&gt;

&lt;p&gt;Type and run the JavaScript below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
  const parentEl = document.querySelector('#parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const newEl = document.createElement('div');
  const newElTwo = document.createElement('div');

  parentEl.append(newEl, newElTwo);
  newEl.append('This is a div tag')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AzKe6MX1IBTrXDOX2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AzKe6MX1IBTrXDOX2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
      &lt;br&gt;
        one&lt;br&gt;
        two&lt;br&gt;
      &lt;br&gt;
    &lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
  const parentEl = document.querySelector('#parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newEl = document.createElement('div');
const newElTwo = document.createElement('div');

parentEl.append(newEl, newElTwo);
newEl.append('This is a div tag')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, we have two new elements in the Document Object Model.&lt;/p&gt;
&lt;h3&gt;
  
  
  After
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.after()&lt;/em&gt; is used to add a new element or text after a specified element within the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
// you can pass in single value&lt;br&gt;
      element.after("Element")&lt;br&gt;
      //you can pass in multiple values&lt;br&gt;
      element.after("string", "string")&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;HTML:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
        &amp;lt;div id="parent"&amp;gt;&lt;br&gt;
          &amp;lt;div id="one"&amp;gt;one&amp;lt;/div&amp;gt;&lt;br&gt;
          &amp;lt;div id="two"&amp;gt;two&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const parentEl = document.querySelector('#parent');&lt;br&gt;
      const one = document.querySelector('#one')&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const newEl = document.createElement('div');
  const newElTwo = document.createElement('div');

  parentEl.append(newEl);
  newEl.append('This is a div tag')

  one.after(newElTwo);
  newElTwo.innerText = 'This is an after() method';
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3lWIhITNF7tBOgzU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3lWIhITNF7tBOgzU.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;div id="parent"&amp;gt;&lt;br&gt;
        &amp;lt;div id="one"&amp;gt;one&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div id="two"&amp;gt;two&amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/div&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
   const parentEl = document.querySelector('#parent');&lt;br&gt;
    const one = document.querySelector('#one')&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newEl = document.createElement('div');
const newElTwo = document.createElement('div');

parentEl.append(newEl);
newEl.append('This is a div tag')

one.after(newElTwo);
newElTwo.innerText = 'This is an after() method';
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
We used the &lt;em&gt;after()&lt;/em&gt; method to insert the newly created &amp;lt; div &amp;gt; tag to come directly after the first element.&lt;/p&gt;
&lt;h3&gt;
  
  
  Before
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.before()&lt;/em&gt; is used to add a new element or text before a specified element within the Document Object Model tree. The &lt;em&gt;before()&lt;/em&gt; do the direct opposite of what &lt;em&gt;after()&lt;/em&gt; does.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
    // you can pass in single value&lt;br&gt;
      element.before("Element")&lt;br&gt;
      //you can pass in multiple values&lt;br&gt;
      element.beforer("string", "string")&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
  &amp;lt;main class="root"&amp;gt;&lt;br&gt;
        &amp;lt;div id="parent"&amp;gt;&lt;br&gt;
          &amp;lt;div id="one"&amp;gt;one&amp;lt;/div&amp;gt;&lt;br&gt;
          &amp;lt;div id="two"&amp;gt;two&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
   const parentEl = document.querySelector('#parent');&lt;br&gt;
      const one = document.querySelector('#one')&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const newEl = document.createElement('div');
  const newElTwo = document.createElement('div');

  parentEl.append(newEl);
  newEl.append('This is a div tag')

  one.before(newElTwo);
  newElTwo.innerText = 'This is an before() method';
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AMOdERlk_GxSZJWdC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AMOdERlk_GxSZJWdC.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
   &lt;br&gt;
      &lt;br&gt;
        one&lt;br&gt;
        two&lt;br&gt;
      &lt;br&gt;
    &lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const parentEl = document.querySelector('#parent');&lt;br&gt;
    const one = document.querySelector('#one')&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newEl = document.createElement('div');
const newElTwo = document.createElement('div');

parentEl.append(newEl);
newEl.append('This is a div tag')

one.before(newElTwo);
newElTwo.innerText = 'This is an before() method';
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The example here is the same as the previous example for &lt;em&gt;after()&lt;/em&gt;. We just replaced the &lt;em&gt;after()&lt;/em&gt; with the &lt;em&gt;before()&lt;/em&gt;. Now notice how the &amp;lt; div &amp;gt; element moves as the element’s first child.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: How To Test &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=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Internet Explorer on Mac&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Remove
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.remove()&lt;/em&gt; removes the specified element from the Document Object Model. When using the method, you don’t have to assign a value to the parentheses.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
element.remove()&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the following example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main&amp;gt;&lt;br&gt;
        &amp;lt;div id="one"&amp;gt;This Remove Element method one&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div id="two"&amp;gt;This Remove Element method two&amp;lt;/div&amp;gt;&lt;br&gt;
        &amp;lt;div id="three"&amp;gt;This Remove Element method three&amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the HTML example above, we have three &amp;lt; div &amp;gt; tags, we are going to remove the second &amp;lt; div &amp;gt; tag with an id of two. Now type and run the JavaScript code below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const removeEl = document.querySelector("#two");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const myEl = removeEl.remove();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2AgZxQuVBVyusOxIY_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2AgZxQuVBVyusOxIY_.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 &lt;br&gt;
      This Remove Element method one&lt;br&gt;
      This Remove Element method two&lt;br&gt;
      This Remove Element method three&lt;br&gt;
    &lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const removeEl = document.querySelector("#two");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myEl = removeEl.remove();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the output, notice we now have just two &amp;lt; div &amp;gt; tags left out of the three we created.&lt;/p&gt;
&lt;h3&gt;
  
  
  setAttribute
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.setAttribute()&lt;/em&gt; sets the attribute of a given element in the Document Object Model tree. The attribute is updated if the given attributes already exist in the element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: &lt;em&gt;When using the set attribute method, the first value takes in the name of the attributes. This might be an id, class, type, or name and then followed by the value you want the attribute to have.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
   element.setAttribute(name, value)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the following example below:&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main&amp;gt;This is set Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The HTML displays just a set text, with a main tag. Now type and run the JavaScript code given below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  myAttribute.setAttribute("id", "my-text");

  console.log(myAttribute);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2546%2F0%2Ahee8gvKXPRiNmGn6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2546%2F0%2Ahee8gvKXPRiNmGn6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main&amp;gt;This is set Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myAttribute.setAttribute("id", "my-text");

console.log(myAttribute);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice the output indicated by the arrow.&lt;/p&gt;
&lt;h3&gt;
  
  
  getAttribute
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.getAttribute()&lt;/em&gt; returns the attribute of a given element in the Document Object Model tree. If the given attribute does not exist in the element, the attribute returns &lt;em&gt;null&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;**Note *&lt;/em&gt;&lt;em&gt;: *When using the get attribute method, you should only reference the name of the attribute you want to get. Also, remember that you can only get one attribute from the given element.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 element.getAttribute(name)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the following example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main id=”my-text”&amp;gt;This is get Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are going to get the id attribute we set earlier. Type and run the JavaScript code given below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
  const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const myAttr = myAttribute.getAttribute("id");

  console.log(myAttr);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2Ad6KvvnU35BYo2kbB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2Ad6KvvnU35BYo2kbB.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
   This is get Attribute Method&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myAttr = myAttribute.getAttribute("id");

console.log(myAttr);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice from the arrow the return name of the id attribute value.&lt;/p&gt;
&lt;h3&gt;
  
  
  getAttributeNames
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.getAttributeNames()&lt;/em&gt; returns the attribute as an array-like string. If the given element does not have an attribute in the element, it returns an empty array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: &lt;em&gt;When using the get attribute method, you don’t have to reference the name of the attributes you want to get.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 element.getAttributeNames()&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the following example below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
This is get Attribute Names Method&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are going to get the name of the given attributes name specified in the element. Type and run the JavaScript below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const myAttr = myAttribute.getAttributeNames();

  console.log(myAttr);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F0%2AnPsqKizPhWBJ9zTv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F0%2AnPsqKizPhWBJ9zTv.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main id="my-text" class="get" name="attribute"&amp;gt;This is get Attribute Names Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myAttr = myAttribute.getAttributeNames();

console.log(myAttr);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice from the arrow the returned attributes as an array.&lt;/p&gt;
&lt;h3&gt;
  
  
  hasAttribute
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;element.hasAttribute()&lt;/em&gt; returns a boolean value of &lt;em&gt;true&lt;/em&gt; if the attribute exists. If the given attribute does not exist in the element, &lt;em&gt;false&lt;/em&gt; is returned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: &lt;em&gt;When using the has attribute method, you should only reference the name of the attribute you want to check. Also, remember that you can only get one attribute from the given element.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
element.hasAttribute(name)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the following example below:&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main id=”my-text”&amp;gt;This is has Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const myAttr = myAttribute.hasAttribute("id");

  console.log(myAttr);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2Aj9uS8ONhDPXdXOiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2Aj9uS8ONhDPXdXOiv.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main id="my-text"&amp;gt;This is has Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myAttr = myAttribute.hasAttribute("id");

console.log(myAttr);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;See the &lt;em&gt;true&lt;/em&gt; value indicated by the arrow.&lt;/p&gt;
&lt;h3&gt;
  
  
  removeAttribute
&lt;/h3&gt;

&lt;p&gt;The element.removeAttribute() removes the attribute of a given element in the DOM tree. If the given attribute does not exist in the element, nothing is returned.&lt;/p&gt;

&lt;p&gt;Note: When using the remove attribute method, you should only reference the name of the attribute you want to remove. Also, remember that you can only remove one attribute from the given element.&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
element.removeAttribute(name)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the following example below:&lt;/p&gt;
&lt;h3&gt;
  
  
  HTML:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main id=”my-text”&amp;gt;This is remove Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are going to remove the id attribute we set earlier. Type and run the JavaScript code given below.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  myAttribute.removeAttribute("id");

  console.log(myAttribute);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Browser Output:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2AfX9h-CaobOwqxRWQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2540%2F0%2AfX9h-CaobOwqxRWQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main id="my-text"&amp;gt;This is remove Attribute Method&amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const myAttribute = document.querySelector("main");&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myAttribute.removeAttribute("id");

console.log(myAttribute);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;See from the arrow that we no longer have an attribute on the element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress Testing&lt;/a&gt; Online- Execute &amp;amp; analyse Cypress test scripts online. Deploy quality builds faster with 40+ browser versions on cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Node Instance Properties
&lt;/h2&gt;

&lt;p&gt;Listed below are some node instance properties we can use to access, add or remove element nodes from the DOM tree.&lt;/p&gt;
&lt;h3&gt;
  
  
  childnodes
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.childnodes&lt;/em&gt; property of the node interface returns a node list of child elements, of a specific element from the DOM tree. This includes elements, texts and comments.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
document.body.childNodes&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
        &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;/ul&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt; &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From this HTML code above, notice we have 6 &amp;lt; li &amp;gt; elements listed out.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.childNodes;
  console.log(getChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3ZHFXY-Jg5kcvW7p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A3ZHFXY-Jg5kcvW7p.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
      &lt;/p&gt;
&lt;ul&gt;

        &lt;li&gt;element one&lt;/li&gt;

        &lt;li&gt;element two&lt;/li&gt;

        &lt;li&gt;element three&lt;/li&gt;

        &lt;li&gt;element four&lt;/li&gt;

        &lt;li&gt;element six&lt;/li&gt;

        &lt;li&gt;element seven&lt;/li&gt;

      &lt;/ul&gt;
&lt;br&gt;
    

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChild = getParent.childNodes;
console.log(getChild
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, the childNodes instance property returns 12 items with a length of 13. As stated earlier, the childNodes instance property returns the given child elements and the texts and comments.&lt;/p&gt;
&lt;h3&gt;
  
  
  firstChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.firstChild&lt;/em&gt; property of the node interface returns the first child of a specific element from the Document Object Model tree and returns a null object when the element has no child.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 document.body.firstChild&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.firstChild;
  console.log(getChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From this code example above and using the same HTML code template we used earlier, we try getting the firstChild node.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Az__k9_xeUCKfOxv2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Az__k9_xeUCKfOxv2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we got a text node as the first child node. This is because the firstChild is a node instance property and not an element. What this means is the firstChild node returns elements, text, or comment. In this case, the firstChild node is a text.&lt;/p&gt;

&lt;p&gt;If what you want to return is the first element instead of a node, try using the &lt;em&gt;firstElementChild&lt;/em&gt; property. The &lt;em&gt;firstElementChild&lt;/em&gt; property has been covered above.&lt;/p&gt;
&lt;h3&gt;
  
  
  lastChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.lastChild&lt;/em&gt; property of the node interface returns the last child of a specific element from the DOM tree and returns a null object when the element has no child.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
document.body.lastChild&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
   const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.lastChild;
  console.log(getChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AisoyakSEJt-W6lUb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AisoyakSEJt-W6lUb.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
      &lt;/p&gt;
&lt;ul&gt;

        &lt;li&gt;element one&lt;/li&gt;

        &lt;li&gt;element two&lt;/li&gt;

        &lt;li&gt;element three&lt;/li&gt;

        &lt;li&gt;element four&lt;/li&gt;

        &lt;li&gt;element six&lt;/li&gt;

        &lt;li&gt;element seven&lt;/li&gt;

      &lt;/ul&gt;
&lt;br&gt;
    

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChild = getParent.lastChild;
console.log(getChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we got a text node as the last child node.&lt;/p&gt;
&lt;h3&gt;
  
  
  Next Sibling
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.nextSibling&lt;/em&gt; property of the node interface returns the next sibling of a specific element of the same level on the DOM tree and returns &lt;em&gt;null&lt;/em&gt; if the element happens to be the last child.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
  document.body.nextSibling&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.firstChild;

  const nextChild = getChild.nextSibling;

  console.log(nextChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Av3XneZ2g8u-gDxOO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Av3XneZ2g8u-gDxOO.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChild = getParent.firstChild;

const nextChild = getChild.nextSibling;

console.log(nextChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we got the first element as the next sibling. This is because, after the text node, the child element comes next.&lt;/p&gt;
&lt;h3&gt;
  
  
  previousSibling
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.previousSibling&lt;/em&gt; property of the node interface returns the previous sibling of a specific element of the same level on the Document Object Model tree. It returns &lt;em&gt;null&lt;/em&gt; if the element happens to be the first child.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
document.body.previousSibling&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.lastChild;

  const previousChild = getChild.previousSibling;

  console.log(previousChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AhIjxFGVZ2vOSry6S.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AhIjxFGVZ2vOSry6S.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChild = getParent.lastChild;

const previousChild = getChild.previousSibling;

console.log(previousChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we got the last element as the previous sibling.&lt;/p&gt;
&lt;h3&gt;
  
  
  Parent Node
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;node.parentNode&lt;/strong&gt; property of the node interface returns the parent element on the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
document.body.parentNode&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.firstChild;

  const returnParent = getChild.parentNode;

  console.log(returnParent)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AbuRdf1YIJfQeae0B.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AbuRdf1YIJfQeae0B.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
  const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChild = getParent.firstChild;

const returnParent = getChild.parentNode;

console.log(returnParent)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output. We used the first child element to return the parent element.&lt;/p&gt;
&lt;h3&gt;
  
  
  textContent
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.textContent&lt;/em&gt; property of the node interface returns or sets the text content of a given element on the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 document.element.textContent&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getChild = getParent.firstChild;

  const returnParent = getChild.parentNode;

  console.log(returnParent.textContent)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AV4nmmNJvBxb-uPNt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AV4nmmNJvBxb-uPNt.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-3 siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-4 siblings"&amp;gt;element four&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-5 siblings"&amp;gt;element six&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-6 siblings"&amp;gt;element seven&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getChild = getParent.firstChild;

const returnParent = getChild.parentNode;

console.log(returnParent.textContent)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test Automation&lt;/a&gt; Tutorial: E2E Testing with Cypress&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Node Instance Methods
&lt;/h2&gt;

&lt;p&gt;Node instance methods are functions that can be called on an instance of a Node.js class or object. These methods have access to the properties and methods of the class or object and can perform actions or manipulate data associated with the instance.&lt;/p&gt;
&lt;h3&gt;
  
  
  AppendChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.appendChild()&lt;/em&gt; method of the node interface adds a child element to a given parent Node in the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
  document.element.appendChild(childElement)&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take the code sample below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
        &lt;/p&gt;
&lt;ul&gt;

          &lt;li&gt;element one&lt;/li&gt;

          &lt;li&gt;element two&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 //The parent element&lt;br&gt;
      const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //The create a new Paragraph
  const newLi = document.createElement('li');

  const insertChild = getParent.appendChild(newLi);
  insertChild.innerText = 'New list Element';

  console.log(insertChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AbjevJW8o9q3ZLL3K.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AbjevJW8o9q3ZLL3K.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//The parent element&lt;br&gt;
    const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//The create a new Paragraph
const newLi = document.createElement('li');

const insertChild = getParent.appendChild(newLi);
insertChild.innerText = 'New list Element';

console.log(insertChild)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we now have three list items instead of the two we have.&lt;/p&gt;
&lt;h3&gt;
  
  
  RemoveChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.removeChild()&lt;/em&gt; method of the node interface removes a child element of a given parent Node in the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
  document.element.removeChild(childElement)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//The parent element&lt;br&gt;
      const getParent = document.querySelector('.parent');&lt;br&gt;
      const childOne = document.querySelector('li[class]');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const firstEl = getParent.removeChild(childOne);

  console.log(firstEl)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ATnQBzks8vqOeboy0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ATnQBzks8vqOeboy0.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-1 siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 //The parent element&lt;br&gt;
    const getParent = document.querySelector('.parent');&lt;br&gt;
    const childOne = document.querySelector('li[class]');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const firstEl = getParent.removeChild(childOne);

console.log(firstEl)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, we now have one element after the first element was removed.&lt;/p&gt;
&lt;h3&gt;
  
  
  replaceChild
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.replaceChild()&lt;/em&gt; method of the node interface replaces a child element with a new child element of a given parent Node in the Document Object Model tree.&lt;/p&gt;

&lt;p&gt;**&lt;em&gt;Note: **the replaceChild method takes in the new child element first and then the old child element you want to replace.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
  document.element.replaceChild(newElement, oldElement)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main class="root"&amp;gt;&lt;br&gt;
        &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
          &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;/ul&amp;gt;&lt;br&gt;
      &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
/The parent element&lt;br&gt;
      const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //List Element we want to replace
  const listEl = document.querySelector('li[class]');

  //create new div element
  const div = document.createElement('div');

  //Replace the list with div element
  const replaceList = getParent.replaceChild(div, listEl);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYFPiOisbp4SyUexJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AYFPiOisbp4SyUexJ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="child-2 siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 //The parent element&lt;br&gt;
    const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//List Element we want to replace
const listEl = document.querySelector('li[class]');

//create new div element
const div = document.createElement('div');

//Replace the list with div element
const replaceList = getParent.replaceChild(div, listEl);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As indicated by the arrow, notice how the list element has been replaced with a div tag.&lt;/p&gt;
&lt;h3&gt;
  
  
  InsertBefore
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;node.insertBefore()&lt;/em&gt; method of the node interface inserts a child element before the specified element of a given parent Node in the Document Object Model tree.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
   document.element.insertBefore(newElement, specifiedElement)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
        &lt;/p&gt;
&lt;ul&gt;

          &lt;li&gt;element one&lt;/li&gt;

          &lt;li&gt;element two&lt;/li&gt;

          &lt;li&gt;element three&lt;/li&gt;

        &lt;/ul&gt;
&lt;br&gt;
       

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//The parent element&lt;br&gt;
      const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //the List element we want to insert element before it
  const listEl = document.querySelector('.childTwo');

  //create new div element
  const div = document.createElement('div');

  //insert div element before list two element 
  const placeDiv = getParent.insertBefore(div, listEl);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AjCk4U79KJT8hZ5ha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AjCk4U79KJT8hZ5ha.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
 &amp;lt;main class="root"&amp;gt;&lt;br&gt;
      &amp;lt;ul class="parent"&amp;gt;&lt;br&gt;
        &amp;lt;li class="childOne siblings"&amp;gt;element one&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="childTwo siblings"&amp;gt;element two&amp;lt;/li&amp;gt;&lt;br&gt;
        &amp;lt;li class="childThree siblings"&amp;gt;element three&amp;lt;/li&amp;gt;&lt;br&gt;
      &amp;lt;/ul&amp;gt;&lt;br&gt;
    &amp;lt;/main&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//The parent element&lt;br&gt;
    const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//the List element we want to insert element before it
const listEl = document.querySelector('.childTwo');

//create new div element
const div = document.createElement('div');

//insert div element before list two element 
const placeDiv = getParent.insertBefore(div, listEl);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console output, notice how the new div element we created was inserted before element two targeted.&lt;/p&gt;
&lt;h3&gt;
  
  
  hasChildNodes
&lt;/h3&gt;

&lt;p&gt;The node*.hasChildNodes()* method of the node interface returns a boolean value of true if the specified element has a child but returns false if the child is not present in the Document Object Model tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;white-space is also treated as a text node (empty string)&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
  document.element.hasChildNodes()&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
        &lt;/p&gt;
&lt;ul&gt;

          &lt;li&gt;element one&lt;/li&gt;

          &lt;li&gt;element two&lt;/li&gt;

          &lt;li&gt;element three&lt;/li&gt;

        &lt;/ul&gt;
&lt;br&gt;
      

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//The parent element&lt;br&gt;
      const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //Check if the parent element has a child node.
  const checkNode = getParent.hasChildNodes();

  console.log(checkNode)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AUpvOPoFcV7Eaax4Y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AUpvOPoFcV7Eaax4Y.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
&lt;br&gt;
      &lt;/p&gt;
&lt;ul&gt;

        &lt;li&gt;element one&lt;/li&gt;

        &lt;li&gt;element two&lt;/li&gt;

        &lt;li&gt;element three&lt;/li&gt;

      &lt;/ul&gt;
&lt;br&gt;
    

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JS:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
//The parent element&lt;br&gt;
    const getParent = document.querySelector('.parent');&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Check if the parent element has a child node.
const checkNode = getParent.hasChildNodes();

console.log(checkNode)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the console out, we have true printed out. This is because the parent has child nodes (Elements).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium automation&lt;/a&gt; Tutorial: A Detailed Guide To Appium Testing&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Difference between DOM Node and Element
&lt;/h2&gt;

&lt;p&gt;The term Document Object Model or DOM node and Element node can be quite confusing, so we must iterate this point for clarity. But first, let’s better understand what Node and Elements are.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Node
&lt;/h2&gt;

&lt;p&gt;The node refers to an interface that serves as a base for other Web API objects in the Document object model (DOM).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Node in the DOM:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below is an HTML document. HTML documents are represented as Nodes and objects. This node allows developers to manipulate the web page using node properties and methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML DOCUMENTS:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br&gt;
      &lt;br&gt;
      &lt;/p&gt;
&lt;br&gt;
          &lt;br&gt;
          &lt;br&gt;
          This is an HTML document&lt;br&gt;
          &lt;br&gt;
      &lt;br&gt;
      &lt;br&gt;
          &lt;br&gt;
              &amp;lt;!-- This is the website Navigation --&amp;gt;&lt;br&gt;
              &lt;br&gt;
                  &lt;br&gt;
                      &lt;ul&gt;

                          &lt;li&gt;HOME&lt;/li&gt;

                          &lt;li&gt;SERVICES&lt;/li&gt;

                          &lt;li&gt;ABOUT&lt;/li&gt;

                      &lt;/ul&gt;
&lt;br&gt;
                  &lt;br&gt;
              
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          &amp;lt;!-- This is the page section --&amp;gt;
          &amp;lt;section&amp;gt;
              &amp;lt;h1&amp;gt;The Document Object Model&amp;lt;/h1&amp;gt;
  &amp;lt;p&amp;gt;The DOM gives web developers the flexibility to be able to manipulate, style and structure element nodes&amp;lt;/p&amp;gt;
          &amp;lt;/section&amp;gt;

          &amp;lt;!-- This is the page button --&amp;gt;
          &amp;lt;button&amp;gt;This is a Button&amp;lt;/button&amp;gt;
      &amp;lt;/main&amp;gt;

  &amp;lt;!-- This is the page footer --&amp;gt;
      &amp;lt;footer&amp;gt;This is a footer&amp;lt;/footer&amp;gt;
  &amp;lt;/body&amp;gt;
  &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the above HTML document, the nodes refer to the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HTML tags&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The text content with the HTML tags&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The HTML comment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Doctype declaration&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The HTML attributes, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;White space (taps, spaces, line-breaks)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these are referred to individually as nodes. So it’s valid to say the attribute node. To refer to only the attribute of the element or comment node to refer to the comments on the page only.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;instance property&lt;/em&gt; and &lt;em&gt;instance methods&lt;/em&gt; are objects in JavaScript for manipulating and updating the nodes in the Document Object Model. This can either be comments, text, white spaces, or elements.&lt;/p&gt;
&lt;h3&gt;
  
  
  White Spaces
&lt;/h3&gt;

&lt;p&gt;It’s important to note that whitespaces are nodes, which are taps, space, and line breaks. These White spaces are usually treated as text, and white spaces between two words are treated as a single character, while white spaces before and after the opening and closing tags are ignored. This helps to structure HTML content when it loads by the browser properly.&lt;/p&gt;

&lt;p&gt;Try this code below.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
  &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;h1&amp;gt;    This   is text    

       contains    white    spaces

    &amp;lt;/h1&amp;gt;

  &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The HTML code above contains white spaces, which are created with space-tap, taps, and line breaks.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AXgKZCZ68rSVD1uTr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2606%2F0%2AXgKZCZ68rSVD1uTr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
 &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;h1&amp;gt;    This   is text    

     contains    white    spaces

  &amp;lt;/h1&amp;gt;

&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, notice how each word is laid out without taps. Based on how the text is formatted and laid out in the Text Editor, the browser removes these extra white spaces and lays out the content in a single line. To add or remove white space is done using CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/black-box-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Black Box Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Element Nodes
&lt;/h2&gt;

&lt;p&gt;The element node refers to the HTML tags. Examples of the element nodes are &amp;lt; p &amp;gt;, &amp;lt; div &amp;gt;, &amp;lt; main &amp;gt;, &amp;lt; h1 &amp;gt; etc. The element node has nothing to do with the text inside it, white spaces, or attributes. These are just separate nodes that can be attached to the element nodes. The element &lt;em&gt;instance properties and methods&lt;/em&gt; are built-in objects that allow developers to manipulate the element nodes.&lt;/p&gt;

&lt;p&gt;It’s important to note that the node &lt;em&gt;instance properties&lt;/em&gt; and &lt;em&gt;methods&lt;/em&gt; differ from the element &lt;em&gt;instance properties&lt;/em&gt; and &lt;em&gt;methods&lt;/em&gt;. The node &lt;em&gt;instance properties and methods&lt;/em&gt; allow access to all node objects, which includes &lt;em&gt;white space, comments, elements, attributes,&lt;/em&gt; etc., while element &lt;em&gt;instance properties and methods&lt;/em&gt; only allow access to the element node. So this should not be used interchangeably.&lt;/p&gt;
&lt;h2&gt;
  
  
  Comment Nodes
&lt;/h2&gt;

&lt;p&gt;The comment nodes are special kinds of nodes. It helps to explain what a particular section of your code is meant to do or is designed to do. Although comments can be accessed or created in a JavaScript environment, you are not necessarily going to be manipulating the comment node with JavaScript since they are not displayed by the browser.&lt;/p&gt;

&lt;p&gt;Here is an example of a comment in HTML.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          &amp;lt;!-- This is a comment node --&amp;gt;

      &amp;lt;!-- 
        # You can also write
        # a comment in 
        # This manner
       --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note the comments mentioned here are HTML comments, not JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/system-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;System Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Difference between HTML Collections and a Node List
&lt;/h2&gt;

&lt;p&gt;If you have read this far, you will have come across where we talked about some elements returning a live &lt;em&gt;HTMLCollection&lt;/em&gt; or &lt;em&gt;NodeList&lt;/em&gt;. We will break it down so that when you come across these terms next, you will know exactly what you are working with.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Collection
&lt;/h2&gt;

&lt;p&gt;This is a group of element nodes (array-like objects). We get an &lt;em&gt;HTMLCollection&lt;/em&gt; when we use instance properties such as &lt;em&gt;children and instance&lt;/em&gt; methods such as &lt;em&gt;getElementsbyTagName()&lt;/em&gt; and &lt;em&gt;getElementsByClassName()&lt;/em&gt;. An HTML collection is said to be live. This is because it auto-updates when a new element is parsed into the existing element.&lt;/p&gt;

&lt;p&gt;An HTMLCollectiont returns only the given elements of the specified elements.&lt;/p&gt;

&lt;p&gt;We have already covered how HTMLCollection works using the &lt;em&gt;children&lt;/em&gt;, &lt;em&gt;getElementsbyTagName()&lt;/em&gt;, and &lt;em&gt;getElementsByClassName()&lt;/em&gt; properties and methods above.&lt;/p&gt;
&lt;h2&gt;
  
  
  Node List
&lt;/h2&gt;

&lt;p&gt;NodeList are node objects. We get a NodeList when we use instance properties such as &lt;em&gt;childNodes and instance methods&lt;/em&gt; such as &lt;em&gt;getElementsbyName()&lt;/em&gt; and &lt;em&gt;querySelectorAll()&lt;/em&gt;. A NodeList is said to be static. This is because it does not auto-update when a new element is parsed into the existing element.&lt;/p&gt;

&lt;p&gt;A NodeList returns all the nodes of the given elements.&lt;/p&gt;

&lt;p&gt;We have already covered how HTMLCollection works using the &lt;em&gt;childNodes&lt;/em&gt;, &lt;em&gt;getElementsbyName()&lt;/em&gt; and &lt;em&gt;querySelectorAll()&lt;/em&gt; properties and methods above.&lt;/p&gt;
&lt;h2&gt;
  
  
  Shadow DOM and Virtual DOM
&lt;/h2&gt;

&lt;p&gt;We have discussed the Document Object Model and its use cases, and another component of the DOM we have to discuss is the Shadow DOM and Virtual DOM.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;**Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Manual Testing&lt;/a&gt; Tutorial: A Comprehensive Guide, with Examples &amp;amp; Best Practices *&lt;/em&gt;*&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Shadow DOM?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/shadow-dom-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Shadow DOM&lt;/a&gt; refers to a separate Document Object Model tree of elements that can be append() into the main Document Object Model tree, but it’s not part of the main Document Object Model tree. However, when parsed by the browser, it behaves like it’s part of the main Document Object Model.&lt;/p&gt;

&lt;p&gt;The shadow DOM gives us the flexibility to be able to work with another tree-like Document Object Model without making any changes to the main Document Object Model structure but using the shadow Document Object Model to add functionality to the page.&lt;/p&gt;

&lt;p&gt;However, since Shadow DOM is a very new feature, browsers have implemented Shadow DOM in different ways and with different limitations. For example, some browsers allow you to use JavaScript in Shadow DOM by default, others don’t; some allow you to set up event handlers in Shadow DOM by default, and others don’t. This means that we still need to test our work across browsers.&lt;/p&gt;

&lt;p&gt;Cloud-based &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platform like LambdaTest lets you perform both exploratory and &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; of Shadow DOM on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ real browsers and operating systems combinations. You can further accelerate your testing cycles by running cross browser tests in parallel and reducing &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; time by multiple folds.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;UI Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Virtual DOM?
&lt;/h2&gt;

&lt;p&gt;Virtual DOM, on the other hand, is a concept mainly found in JavaScript frameworks such as &lt;em&gt;React.js&lt;/em&gt; and &lt;em&gt;Vue.js&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is a direct representation or copy of the main Document Object Model into a memory called a Virtual DOM. This Virtual DOM has the same tree-like structure as the main Document Object Model. So anytime a change is made to the JSX or (JS) file, an update is made to the Virtual DOM.&lt;/p&gt;

&lt;p&gt;In turn, the Virtual DOM refers to the part of the Document Object Model, where the changes were made and then provides necessary changes to the main Document Object Model.&lt;/p&gt;

&lt;p&gt;This helps reduce the load time it would take if the changes were made directly to the main Document Object Model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/agile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan25_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Agile Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Differences between Shadow DOM and Virtual DOM
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Shadow DOM&lt;/em&gt; and &lt;em&gt;Virtual DOM&lt;/em&gt; are very different. Shadow DOM is a web component API and exists in major browsers locally. While Virtual DOM is an implementation by JavaScript frameworks like react.js and vue.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We just covered a complete guide to Document Object Model (DOM). And we covered the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What is the Document Object Model (DOM),&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The DOM structure and DOM tree,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accessing the DOM interface&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Document instance properties and methods&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node instance properties and methods&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Difference between DOM Node and Element&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTMLCollection and NodeList&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is Shadow and Virtual DOM&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alright! We’ve come to the end of this blog on Document Object Model.&lt;/p&gt;

&lt;p&gt;Thanks for taking your time to read this article to completion. Feel free to ask questions. I’ll gladly reply. You can find me on Twitter, and other social media @ocxigin.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cheers
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>A Beginner’s Guide To Styling CSS Forms</title>
      <dc:creator> Alex Anie</dc:creator>
      <pubDate>Mon, 19 Dec 2022 14:15:54 +0000</pubDate>
      <link>https://forem.com/testmuai/a-beginners-guide-to-styling-css-forms-1l92</link>
      <guid>https://forem.com/testmuai/a-beginners-guide-to-styling-css-forms-1l92</guid>
      <description>&lt;p&gt;To put in a simple term, an HTML or web forms are mostly referred to as web elements that are designed to enable users to put in their information, which may include their names, age, gender, or credit card number, etc., which is then sent to a server for processing.&lt;/p&gt;

&lt;p&gt;Web forms are very useful and are now a very important aspect of &lt;a href="https://www.lambdatest.com/blog/top-21-web-development-trends-in-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;web development&lt;/a&gt;. Imagine having to travel to a foreign country just to fill out a form because you want to apply for a course in their university.&lt;/p&gt;

&lt;p&gt;Since every modern university has a website with a form, students can sit in the comfort of their homes and apply within their convenient time, saving them the time to visit the school in person. Then the school collects this information to decide if the candidate is qualified to study at their university.&lt;/p&gt;

&lt;p&gt;Web forms are not limited to schools only, businesses such as Banks, E-Commerce, to mention a few, use web forms to collect information from their customers. This helps them decide how to serve the needs of their customers better.&lt;/p&gt;

&lt;p&gt;This is exactly what web forms are designed to do — to collect information for processing.&lt;/p&gt;

&lt;p&gt;In this tutorial on CSS Forms, we will take a closer look at how to style forms with CSS and much more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites for styling CSS Forms
&lt;/h2&gt;

&lt;p&gt;By the end of this tutorial on CSS Forms, you would be in a position to build a form in HTML that is styled using CSS. However, a basic knowledge of HTML and CSS is required to understand this blog on CSS Forms better.&lt;/p&gt;

&lt;p&gt;Here is a sample of the finished project of what we’ll be building.&lt;/p&gt;

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

&lt;p&gt;Here is the link to CodePen for this styling CSS Form project’s source code.&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;How to style forms with CSS: A beginner’s guide&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div class="site__container"&amp;gt;
    &amp;lt;main class="hero__images"&amp;gt;
      &amp;lt;main class="card__wrapper"&amp;gt;
        &amp;lt;!-- background for the form --&amp;gt;
        &amp;lt;section class="card__forms"&amp;gt;

          &amp;lt;!-- Wrapper for all items of the box --&amp;gt;
          &amp;lt;section class="items__wrapper"&amp;gt;

            &amp;lt;div class="site__logo"&amp;gt;MS&amp;lt;/div&amp;gt;
            &amp;lt;div class="sign__caption"&amp;gt;
              &amp;lt;p&amp;gt;Signin for home delivery service&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="user_id"&amp;gt;
              &amp;lt;!-- user id options for username and password --&amp;gt;
              &amp;lt;input type="text" name="Username" placeholder="Username"&amp;gt;
              &amp;lt;input type="password" name="Password" placeholder="Password"&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="checkbox__wrapper"&amp;gt;
              &amp;lt;!-- Input filed for checkbox and forget password --&amp;gt;
              &amp;lt;input type="checkbox" name="checkbox"&amp;gt;
              &amp;lt;label for="checkbox"&amp;gt;stay signed in&amp;lt;/label&amp;gt; 
              &amp;lt;a href="#"&amp;gt;Forget Password?&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="btn__wrapper"&amp;gt;
              &amp;lt;!-- Sign in button --&amp;gt;
              &amp;lt;button class="btn__signin"&amp;gt;sign in&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="signup__option"&amp;gt;
              &amp;lt;!-- Sign up opption for new users --&amp;gt;
              &amp;lt;p&amp;gt;Don't have an accout yet? &amp;lt;a href="#"&amp;gt;Sign Up!&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/section&amp;gt;
        &amp;lt;/section&amp;gt;
      &amp;lt;/main&amp;gt;
    &amp;lt;/main&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;CSS:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*, *::after, *::before {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.site__container {
    width: 100vw;
    height: 100vh;
}

.hero__images {
    height: 100%;
    /* background-image: url("Screenshot\ \(209\).png"); */
    background-image: url("https://i.postimg.cc/NfX1S37K/delivery-man.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    /* background-color: aqua; */
}

.card__wrapper {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card__forms {
    display: flex;
    justify-content: center;
    width: 400px;
    height: 400px;
    background-color: rgb(1, 32, 32, 0.4);
    border-radius: 0.5rem;
    box-shadow: 3.5px 3.5px 4px 2px rgba(0, 0, 0, 0.3);
    /* border: 1px solid rgb(89, 250, 156); */
    border-top: 2px solid rgb(89, 250, 156);
    border-bottom: 2px solid rgb(89, 250, 156);
}

.site__logo {
    width: 40px;
    padding: 4px;
    margin: 2.0rem 5rem;
    text-align: center;
    border-radius: 4px;
    font-size: x-large;
    font-weight: bolder;
    font-family: 'Trebuchet MS', sans-serif;
    background-color: rgb(89, 250, 156);
    color: rgb(1, 32, 32);
    border-radius: 50%;
    cursor: default;
}

.sign__caption p {
    color: white;
    font-family: calibri;
    font-style: italic;
    text-transform: lowercase;
    margin-bottom: 1.5rem;
}

.user_id input {
    width: 100%;
    display: block;
    outline: none;
    border: 0;
    padding: 1rem;
    border-radius: 20px;
    margin: 0.8rem 0;
    color: rgb(1, 32, 32);
}

.user_id input::placeholder{
    color: rgb(1, 32, 32);
}

.user_id input:active {
    outline: 2px solid rgb(89, 250, 156);
}


.checkbox__wrapper label {
        color: white;
        font-family: calibri;
        text-transform: lowercase;
}

.checkbox__wrapper a {
        color: rgb(89, 250, 156);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: italic;
}

.checkbox__wrapper a:hover {
        color: rgb(255, 255, 255);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: normal;
}

.btn__wrapper button {
    width: 100%;
    border: none;
    padding: 1rem;
    border-radius: 20px;
    text-transform: uppercase;
    font-weight: bolder;
    margin: 0.8rem 0;
    color: rgb(1, 32, 32);
}

.btn__wrapper button:hover {
    background-color: rgb(89, 250, 156); 
    color: white;
    transition: all 0.5s ease-in-out;
    cursor: pointer;
}

.signup__option p {
    color: white;
        font-family: calibri;
        text-transform: lowercase;
}
.signup__option a {
        color: rgb(89, 250, 156);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: italic;
}

.signup__option a:hover {
    color: rgb(255, 255, 255);
    font-family: calibri;
    text-transform: lowercase;
    text-decoration: none;
    font-style: normal;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Creating the HTML boilerplates
&lt;/h2&gt;

&lt;p&gt;Let’s start by creating the website boilerplates (that is, the HTML code structure for the website). This contains the head and body tags, as seen below.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
 &amp;lt;meta charset="UTF-8"&amp;gt;
 &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
 &amp;lt;meta name="viewport" content="width=device-width,initial-scale=1.0"&amp;gt;
 &amp;lt;title&amp;gt;How to style forms with CSS: A beginner's guide&amp;lt;/title&amp;gt;
      &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After creating our HTML boilerplate, now save it as an &lt;strong&gt;index.html&lt;/strong&gt; file, am using VS Code but you can use any IDE of your choice.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hey here’s a quick free tool called &lt;a href="https://www.lambdatest.com/free-online-tools/rem-to-px-converter?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;rem-to-px-converter&lt;/a&gt; &amp;amp; &lt;a href="https://www.lambdatest.com/free-online-tools/px-to-rem-converter?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;px-to-rem-converter&lt;/a&gt; that will help you convert CSS unit REM values &amp;amp; pixels.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the necessary HTML tags
&lt;/h2&gt;

&lt;p&gt;Now, let’s create the necessary HTML tags for our styling CSS Forms project.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class="site__container"&amp;gt;
  &amp;lt;main class="hero__images"&amp;gt;
 &amp;lt;main class="card__wrapper"&amp;gt;
 &amp;lt;!-- background for the form --&amp;gt;
     &amp;lt;section class="card__forms"&amp;gt;

     &amp;lt;!-- Wrapper for all items of the box --&amp;gt;
    &amp;lt;section class="items__wrapper"&amp;gt;

   &amp;lt;div class="site__logo"&amp;gt;MS&amp;lt;/div&amp;gt;
    &amp;lt;div class="sign__caption"&amp;gt;
    &amp;lt;p&amp;gt;Signin for home delivery service&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="user_id"&amp;gt;
   &amp;lt;!-- user id options for username and password --&amp;gt;
      &amp;lt;input type="text" name="Username" placeholder="Username"&amp;gt;
      &amp;lt;input type="password" name="Password" placeholder="Password"&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="checkbox__wrapper"&amp;gt;
   &amp;lt;!-- Input field for checkbox and forget password --&amp;gt;
     &amp;lt;input type="checkbox" name="checkbox"&amp;gt;
     &amp;lt;label for="checkbox"&amp;gt;stay signed in&amp;lt;/label&amp;gt; 
     &amp;lt;a href="#"&amp;gt;Forget Password?&amp;lt;/a&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="btn__wrapper"&amp;gt;
   &amp;lt;!-- Sign in button --&amp;gt;
    &amp;lt;button class="btn__signin"&amp;gt;sign in&amp;lt;/button&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="signup__option"&amp;gt;
   &amp;lt;!-- Sign up option for new users --&amp;gt;
   &amp;lt;p&amp;gt;Don't have an account yet? 
                    &amp;lt;a href="#"&amp;gt;Sign Up!&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
           &amp;lt;/section&amp;gt;
     &amp;lt;/section&amp;gt;
      &amp;lt;/main&amp;gt;
        &amp;lt;/main&amp;gt;
      &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the code sample above, let’s look at what each tag is supposed to do based on the class names assigned to them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;site__container&lt;/strong&gt;: This class is assigned to a &lt;strong&gt;div tag&lt;/strong&gt; that wraps around every other tag within our HTML tags.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;hero__images&lt;/strong&gt;: This class is assigned to the &lt;strong&gt;main tag&lt;/strong&gt;. This tag is where our hero image will be assigned using CSS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;card__wrapper&lt;/strong&gt;: This class is assigned to another main tag nested inside the hero__image tag. This tag wraps around all tags that make up our web form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;card__forms&lt;/strong&gt;: This class is assigned to the section tag, which is the main tag for our web form&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Items__wrapper&lt;/strong&gt;: This tag wraps around the &lt;strong&gt;div, input, button&lt;/strong&gt;, and &lt;strong&gt;link tags&lt;/strong&gt; which are items within the web form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;site__logo&lt;/strong&gt;: This is the site logo.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;sign__caption&lt;/strong&gt;: This tag helps to inform the user why they should sign up/sign in using the web form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;user_id&lt;/strong&gt;: This wraps around the &lt;strong&gt;input&lt;/strong&gt; tag where the user has to enter their username and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;checkbox__wrapper&lt;/strong&gt;: This wraps around the &lt;strong&gt;input, a (anchor),&lt;/strong&gt; and **labels **tag. Here we ask the user if they would like their user id to be saved so that they don’t have to retype them later when they visit the site by clicking the checkbox. We also ask if they have a forgotten password that needs to be recovered.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;btn__wrapper&lt;/strong&gt;: This wraps around the main button of the form. This is the button the user clicks on that helps them &lt;strong&gt;sign in&lt;/strong&gt; to the site.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;signup__option&lt;/strong&gt;: This tag wraps around the paragraph tag and a link tag. Here we provide an option for new users who don’t have an account to &lt;strong&gt;signup&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we have the HTML boilerplate setup, save it and run it on your favorite browser. The code in this CSS Forms tutorial is run using Google Chrome.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AoJaiaMlzEZDBZTBd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AoJaiaMlzEZDBZTBd.png" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your code should look like this. You will notice how plain and simple the website is from our browser output. This is because we have not added the CSS yet. In the next section of this tutorial on CSS Forms, we’ll talk about this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Ay2FVjW8qjIpY3AEk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Ay2FVjW8qjIpY3AEk.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Automation Testing&lt;/a&gt; Platform- Accelerate your release velocity with blazing fast test automation on cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to style common form elements with CSS?
&lt;/h2&gt;

&lt;p&gt;Form elements are some of the most common elements on a website. Every site must have these elements, from login forms to search boxes and buttons, to be functional. These elements are sometimes overlooked in design and styling, which may cause them to blend into each other, making your site’s UI look dull. A good way to avoid this is by using CSS to change the appearance of form elements such as text fields and buttons.&lt;/p&gt;

&lt;p&gt;Here’s how you can style common CSS Form elements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your Visual Studio Code, create a new file and name it &lt;strong&gt;main.css&lt;/strong&gt;. This is going to be the CSS file. Notice from our HTML file that in the head tag, we have a link tag that points to &lt;strong&gt;main.css&lt;/strong&gt;. This link tag helps us link together both the HTML and CSS files. Any changes to the HTML will affect the CSS file &amp;amp; vice versa.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aj53_ENKhD_Mq46Kc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aj53_ENKhD_Mq46Kc.png" width="800" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Let’s add the relevant CSS code in &lt;strong&gt;main.css&lt;/strong&gt; so that we can style the boring page that we earlier created using HTML.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ARGSrHHzj319wBtM6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ARGSrHHzj319wBtM6.png" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- Your editor should open as thus. Now let’s write some CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Test On &lt;br&gt;
&lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android Emulator&lt;/a&gt;- Test your web and mobile apps on Android Emulators online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Appling universal selector
&lt;/h2&gt;

&lt;p&gt;Universal selector is a CSS concept that lets you define styles once and reuse them across the entire website. It means that you need to define only that “one thing” once, and then you can use it on other pages. This saves us a lot of time and makes the code more maintainable.&lt;/p&gt;

&lt;p&gt;Type and run the code below for your CSS Forms project:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*, *::after, *::before {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ArJfeU8Jt-Dwq1rTP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ArJfeU8Jt-Dwq1rTP.png" width="799" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the CSS code above, we use a CSS &lt;strong&gt;universal selector&lt;/strong&gt; to target all the elements on the webpage. We added a &lt;strong&gt;padding 0px&lt;/strong&gt;, &lt;strong&gt;margin 0px&lt;/strong&gt; and &lt;strong&gt;box-sizing&lt;/strong&gt; of the &lt;strong&gt;border-box&lt;/strong&gt;. This helps to remove all the white spaces on the webpage so that we don’t have unnecessary white spaces interfering when styling CSS Forms.&lt;/p&gt;
&lt;h2&gt;
  
  
  Applying viewport width (vw) and viewport height (vh)
&lt;/h2&gt;

&lt;p&gt;Applying viewport width (vw) and viewport height (vh) are new properties available in CSS3 and have quite a few uses. By default, the vw unit is equal to 1% of the containing element’s width. The same goes for vh. Using these properties, you can do some cool things with your website.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.site__container {
    width: 100vw;
    height: 100vh;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;We target a &lt;strong&gt;div&lt;/strong&gt; tag with a class of &lt;strong&gt;.site__container&lt;/strong&gt; and we assign a **width **and **height **of **100vw **and **100vh **to both respectively. This helps to size our webpage’s viewport to take the browser’s full width and height.&lt;/p&gt;

&lt;p&gt;You will not see any effect when you refresh your browser since other HTML tags have not been given specific sizing or styling.&lt;/p&gt;

&lt;p&gt;Test browser compatibility of your CSS Forms. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Applying hero image
&lt;/h2&gt;

&lt;p&gt;The hero image is a common element in blog design. It’s a large, eye-catching image that spans the full width of the page and often a bit of the page’s height. It is usually used to draw initial attention to an article or page and as an anchor point for future articles or pages within that site section. A hero image can also highlight content such as images, videos, or other interactive elements by making it the central point of focus on the page.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hero__images {
    height: 100%;
    background-image: url("./delivery-man.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A48gcIZh_nQEAEU6a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A48gcIZh_nQEAEU6a.png" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the CSS code above, we assigned a &lt;strong&gt;height&lt;/strong&gt; of &lt;strong&gt;100%&lt;/strong&gt; to the class of &lt;strong&gt;hero__images&lt;/strong&gt;. This helps the &lt;strong&gt;hero__images **class to inherit the same height value set to the direct parent, which is **100vh&lt;/strong&gt;. This helps the background image used to occupy the browser viewport, and then we set a &lt;strong&gt;background-image&lt;/strong&gt;. You can download the image here.&lt;/p&gt;

&lt;p&gt;We also added a &lt;strong&gt;background-repeat&lt;/strong&gt; of &lt;strong&gt;no-repeat&lt;/strong&gt; to prevent it from repeating, a &lt;strong&gt;background-size&lt;/strong&gt; of &lt;strong&gt;cover&lt;/strong&gt;, which helps to set the image to cover the entire viewport, and a &lt;strong&gt;background-position&lt;/strong&gt; of center, which helps to center the image within the viewport or container.&lt;/p&gt;
&lt;h2&gt;
  
  
  Centering the form with Flexbox
&lt;/h2&gt;

&lt;p&gt;Centering the form with &lt;a href="https://www.lambdatest.com/blog/css-flexbox-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS Flexbox&lt;/a&gt; is easy. The only problem is that it requires you to wrap the form in a parent container with a specified width, which is a bit of a pain. Thankfully, there’s a better solution that works in all browsers. You’ll need three elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The actual form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A wrapper element (parent).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An element for the actual content (child).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’ll use CSS Flexbox to center the web form to the browser center. Type and run the code below.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.card__wrapper {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Ayr58ZQASOvuDQtP-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2Ayr58ZQASOvuDQtP-.png" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the section of styling CSS Forms tutorial, we target the &lt;strong&gt;card__wrapper **class, we set a **height **of **100%&lt;/strong&gt;, a &lt;strong&gt;display **of **flex, justify-content&lt;/strong&gt; of &lt;strong&gt;center&lt;/strong&gt;, and &lt;strong&gt;align-items&lt;/strong&gt; of &lt;strong&gt;center&lt;/strong&gt;. This helps to position the form to the center horizontally and vertically while styling CSS Forms.&lt;/p&gt;
&lt;h2&gt;
  
  
  Styling the form element
&lt;/h2&gt;

&lt;p&gt;The HTML for a typical form consists of various input elements, each representing a different type of data. In CSS, you can style the input element in various ways to create distinction among them.&lt;/p&gt;

&lt;p&gt;Here we apply styling to the CSS Form and add a specific width and height.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.card__forms {
    display: flex;
    justify-content: center;
    width: 400px;
    height: 400px;
    background-color: rgb(1, 32, 32, 0.4);
    border-radius: 0.5rem;
    box-shadow: 3.5px 3.5px 4px 2px rgba(0, 0, 0, 0.3);
    border-top: 2px solid rgb(89, 250, 156);
    border-bottom: 2px solid rgb(89, 250, 156);
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ASpolSPuQCLNVIBVI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ASpolSPuQCLNVIBVI.png" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We target the class of &lt;strong&gt;card__form&lt;/strong&gt;, apply a &lt;strong&gt;display **of **flex&lt;/strong&gt;, &lt;strong&gt;justify-content&lt;/strong&gt; of &lt;strong&gt;center&lt;/strong&gt;, &lt;strong&gt;width&lt;/strong&gt;, and &lt;strong&gt;height **of **400px&lt;/strong&gt; across, to give it a defined size, &lt;strong&gt;background-color&lt;/strong&gt; of &lt;strong&gt;rgb(1, 32, 32, 0.4)&lt;/strong&gt;. The last two integers of &lt;strong&gt;0.4&lt;/strong&gt; are transparent values as they represent the &lt;strong&gt;opacity **of the **0.4 **value. We also added a **border-radius of 0.5em, box-shadow, border-top&lt;/strong&gt;, and &lt;strong&gt;border-bottom&lt;/strong&gt; of &lt;strong&gt;2px solid rgb(89, 250, 156)&lt;/strong&gt;. This creates the solid lime color you can see at the top and bottom of our CSS Form.&lt;/p&gt;
&lt;h2&gt;
  
  
  Styling form logo
&lt;/h2&gt;

&lt;p&gt;Many websites use the form logo to style the input field and submit button in a form. The first reason is that the form is consistent with the overall design. The second reason is that it makes it easier to differentiate between a regular input field and a submit button since the color is used for the submit button.&lt;/p&gt;

&lt;p&gt;Here we apply styling to the logo on the form element.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.site__logo {
    width: 40px;
    padding: 4px;
    margin: 2.0rem 5rem;
    text-align: center;
    border-radius: 50%;
    font-size: x-large;
    font-weight: bolder;
    font-family: 'Trebuchet MS', sans-serif;
    background-color: rgb(89, 250, 156);
    color: rgb(1, 32, 32);
    cursor: default;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A6W5FWd4_I4NIfRAU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2A6W5FWd4_I4NIfRAU.png" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We targeted the &lt;strong&gt;site__logo&lt;/strong&gt; class and we added a &lt;strong&gt;width **of **40px&lt;/strong&gt;, &lt;strong&gt;padding **of **4px&lt;/strong&gt;, **margin **of **2.0rem **and **5rem **for top and bottom respectively (to add extra white space).&lt;/p&gt;

&lt;p&gt;We also apply &lt;strong&gt;text-align&lt;/strong&gt; to &lt;strong&gt;center **(to center the logo), **border-radius&lt;/strong&gt; of &lt;strong&gt;50% **(to make the logo round), **font-size&lt;/strong&gt; of &lt;strong&gt;x-large, font-weight&lt;/strong&gt; of &lt;strong&gt;bolder&lt;/strong&gt;, and &lt;strong&gt;font-family&lt;/strong&gt; of ‘&lt;strong&gt;Trebuchet MS&lt;/strong&gt;‘.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And a background-color&lt;/strong&gt; of &lt;strong&gt;rgb(89, 250, 156)&lt;/strong&gt;, &lt;strong&gt;color **of **rgb(1, 32, 32)&lt;/strong&gt; and &lt;strong&gt;cursor **of **default&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Styling site caption
&lt;/h2&gt;

&lt;p&gt;The site caption is a little bit of text that appears at the top of every page on your website. This can be any text you want. It is typically used to identify who created the site and possibly provide legal information about the site’s content.&lt;/p&gt;

&lt;p&gt;By styling this text, we can make it stand out more or appear in multiple places on a page.&lt;/p&gt;

&lt;p&gt;Here we apply styling to the caption on the CSS Form.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.sign__caption p {
    color: white;
    font-family: calibri;
    font-style: italic;
    text-transform: lowercase;
    margin-bottom: 1.5rem;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ADLSKwfGfDZ3Zqwar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ADLSKwfGfDZ3Zqwar.png" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We selected the &lt;strong&gt;sign__caption **class and targeted the **p&lt;/strong&gt; tag inside it. We apply a text &lt;strong&gt;color **of **white&lt;/strong&gt;, &lt;strong&gt;font-family&lt;/strong&gt; of &lt;strong&gt;calibri&lt;/strong&gt;, &lt;strong&gt;font-style **of **italic&lt;/strong&gt;, &lt;strong&gt;text-transform&lt;/strong&gt; to &lt;strong&gt;lowercase&lt;/strong&gt;, and &lt;strong&gt;margin-bottom&lt;/strong&gt; of &lt;strong&gt;0.5rem&lt;/strong&gt; (to apply extra white space at the bottom).&lt;/p&gt;
&lt;h2&gt;
  
  
  Styling the input tag
&lt;/h2&gt;

&lt;p&gt;The input tag comes with a few styles by default. It has the look of a text field, and it’s a good idea to use the default styling for the most part. The default styling provides enough contrast between elements so that users can easily read and understand what they’re filling in.&lt;/p&gt;

&lt;p&gt;Here we apply styling to the input tag on CSS Form, where users can enter their information.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.user_id input {
    width: 100%;
    display: block;
    outline: none;
    border: 0;
    padding: 1rem;
    border-radius: 20px;
    margin: 0.8rem 0;
    color: rgb(1, 32, 32);
}

.user_id input::placeholder{
    color: rgb(1, 32, 32);
}

.user_id input:active {
    outline: 2px solid rgb(89, 250, 156);
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ALyD3YOHXNQQL5v_k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2ALyD3YOHXNQQL5v_k.png" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We apply the following values from the code sample above to the input tag nested inside the user id class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;width&lt;/strong&gt;: of &lt;strong&gt;100%&lt;/strong&gt; (so that our input tag takes in a full size within the container).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;display&lt;/strong&gt;: of a *&lt;em&gt;block *&lt;/em&gt;(so the tag can be centered properly).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;outline&lt;/strong&gt;: of *&lt;em&gt;none *&lt;/em&gt;(to remove the outline around the input tag when we click on it).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border&lt;/strong&gt;: to *&lt;em&gt;0px *&lt;/em&gt;(to remove the gray border around the input tag).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;padding&lt;/strong&gt;: of *&lt;em&gt;1rem *&lt;/em&gt;(to add more space within the tag input tag to give room for user’s input such as usernames and passwords).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-radius&lt;/strong&gt;: of *&lt;em&gt;20px *&lt;/em&gt;(to give it a rounded curve at the edge).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;margin&lt;/strong&gt;: of &lt;strong&gt;0.8rem 0 (0.8rem&lt;/strong&gt; added extra space at the top and bottom while the 0 means no space should be added to the left and right of the input tag).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;color&lt;/strong&gt;: of &lt;strong&gt;rgb(1, 32, 32)&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the &lt;strong&gt;placeholder&lt;/strong&gt;, we added a text color of &lt;strong&gt;rgb(1, 32, 32)&lt;/strong&gt;, which is responsible for the Username and Password text. And for the &lt;strong&gt;active **state, we added an **outline **color of **2px solid rgb(89, 250, 156)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You will see the outline color when you click on the input field of CSS Form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/ad-hoc-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Ad Hoc Testing&lt;/a&gt;: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Styling forget password
&lt;/h2&gt;

&lt;p&gt;It is necessary to style the password field and its labels in the forgot-password form. You may require to use for this purpose a combination of standard CSS properties and some custom properties.&lt;/p&gt;

&lt;p&gt;Here, we apply styling to the **label **and **a **tag, providing two options for users who want their account to remain signed in and for users who forgot their password to recover it.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.checkbox__wrapper label {
        color: white;
        font-family: calibri;
        text-transform: lowercase;
}

.checkbox__wrapper a {
        color: rgb(89, 250, 156);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: italic;
}

.checkbox__wrapper a:hover {
        color: rgb(255, 255, 255);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: normal;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AXcnQ811GTxPC7q7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AXcnQ811GTxPC7q7s.png" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial section on CSS Forms, we targeted the &lt;strong&gt;label&lt;/strong&gt; tag nested inside the &lt;strong&gt;.checkbox__wrapper&lt;/strong&gt; class and applied the following styling to it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;color&lt;/strong&gt;: of white, a font-family of calibri&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;text-transform&lt;/strong&gt;: of lowercase, while on the anchor tag, we applied a&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;color&lt;/strong&gt;: of rgb(89, 250, 156),&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;text-decoration&lt;/strong&gt;: to none (to remove the default blue line on the anchor tag)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;font-style&lt;/strong&gt; to italic to differentiate it from the label text.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since the anchor tag is a link that is meant to send a request, we decided to add a hover state, which is something to notify the user that this is a clickable link.&lt;/p&gt;

&lt;p&gt;On hover state, we added a text &lt;strong&gt;color&lt;/strong&gt; of &lt;strong&gt;rgb(255, 255, 255)&lt;/strong&gt; on hover, and the &lt;strong&gt;font-style&lt;/strong&gt; is set to &lt;strong&gt;normal&lt;/strong&gt; to restore it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Style the form button
&lt;/h2&gt;

&lt;p&gt;The form button is the first thing a user will see on your website. A nice button can make a good impression, but a bad one can leave a user with a bad taste in their mouth before they even get to read any content.&lt;/p&gt;

&lt;p&gt;Here we apply styling to the button tag on CSS Form. This button enables the user to sign into the website.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.btn__wrapper button {
    width: 100%;
    border: none;
    padding: 1rem;
    border-radius: 20px;
    text-transform: uppercase;
    font-weight: bolder;
    margin: 0.8rem 0;
    color: rgb(1, 32, 32);
}

.btn__wrapper button:hover {
    background-color: rgb(89, 250, 156); 
    color: white;
    transition: all 0.5s ease-in-out;
    cursor: pointer;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AlVoNMbnaeGI4N94j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AlVoNMbnaeGI4N94j.png" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this section of this tutorial on CSS Forms, we targeted the button tag nested in the **btn__wrapper **class, and we applied:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;width&lt;/strong&gt;: of &lt;strong&gt;100%&lt;/strong&gt; to make it have a full width within the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border&lt;/strong&gt;: is set to **none **to remove the gray border around the button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;padding&lt;/strong&gt;: of &lt;strong&gt;1rem&lt;/strong&gt; to add space between the “SIGN IN” text and the button tag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;border-radius&lt;/strong&gt;: of &lt;strong&gt;20px&lt;/strong&gt; to apply a round corner style to the border.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;text-transform&lt;/strong&gt;: is set to &lt;strong&gt;uppercase&lt;/strong&gt; to capitalize the text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;font-weight&lt;/strong&gt;: is set to &lt;strong&gt;bolder&lt;/strong&gt; to make text bold.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;margin:&lt;/strong&gt; is set to &lt;strong&gt;0.8rem&lt;/strong&gt; at the &lt;strong&gt;top&lt;/strong&gt; and &lt;strong&gt;bottom&lt;/strong&gt; to give white space around the object, while &lt;strong&gt;0&lt;/strong&gt; at the &lt;strong&gt;left&lt;/strong&gt; and &lt;strong&gt;right&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;color&lt;/strong&gt; of &lt;strong&gt;rgb(1, 32, 32)&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On hover, we set the &lt;strong&gt;background-color&lt;/strong&gt; to &lt;strong&gt;rgb(89, 250, 156)&lt;/strong&gt;, text &lt;strong&gt;color&lt;/strong&gt; to &lt;strong&gt;white&lt;/strong&gt; to create a kind of invert effect when we hover over it, a &lt;strong&gt;transition of all 0.5s ease-in-out&lt;/strong&gt;, and a &lt;strong&gt;cursor&lt;/strong&gt; of a &lt;strong&gt;pointer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To see these changes, move your mouse pointer to hover on the button.&lt;/p&gt;
&lt;h2&gt;
  
  
  Styling the signup option
&lt;/h2&gt;

&lt;p&gt;The actual signup option is styled to look like a button. The design of the button is simple and recognizable so that users will know what it does. The input size for the email address is a bit smaller than usual to ensure that the user doesn’t have to scroll up and down every time they want to add an email address.&lt;/p&gt;

&lt;p&gt;Here we apply styling to the &lt;strong&gt;p&lt;/strong&gt; and &lt;strong&gt;a&lt;/strong&gt; tag, where we provide options for users who don’t have an account yet but would want to sign up.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .signup__option p {
    color: white;
        font-family: calibri;
        text-transform: lowercase;
}
.signup__option a {
        color: rgb(89, 250, 156);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: italic;
}

.signup__option a:hover {
    color: rgb(255, 255, 255);
    font-family: calibri;
    text-transform: lowercase;
    text-decoration: none;
    font-style: normal;
}
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AU_0BcP3jeZAjoyhR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AU_0BcP3jeZAjoyhR.png" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the browser output, you will notice that the “&lt;strong&gt;stay signed in / forgot password&lt;/strong&gt;” and “&lt;strong&gt;don’t have an account yet? / sign up!&lt;/strong&gt;” looks the same. Well, you guessed it right!&lt;/p&gt;

&lt;p&gt;We have to copy the CSS styles for the &lt;strong&gt;label&lt;/strong&gt; tag of the &lt;strong&gt;checkbox_&lt;em&gt;wrapper *&lt;em&gt;class and paste it on *&lt;/em&gt;.signup&lt;/em&gt;_option a&lt;/strong&gt; and then copy the styles on &lt;strong&gt;forget password&lt;/strong&gt; and paste it on the &lt;strong&gt;sign up&lt;/strong&gt; class.&lt;/p&gt;

&lt;p&gt;Now we should have the same effect.&lt;/p&gt;

&lt;p&gt;Here is the link to the finished project on styling CSS Forms.&lt;/p&gt;

&lt;p&gt;HTML:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;How to style forms with CSS: A beginner’s guide&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div class="site__container"&amp;gt;
    &amp;lt;main class="hero__images"&amp;gt;
      &amp;lt;main class="card__wrapper"&amp;gt;
        &amp;lt;!-- background for the form --&amp;gt;
        &amp;lt;section class="card__forms"&amp;gt;

          &amp;lt;!-- Wrapper for all items of the box --&amp;gt;
          &amp;lt;section class="items__wrapper"&amp;gt;

            &amp;lt;div class="site__logo"&amp;gt;MS&amp;lt;/div&amp;gt;
            &amp;lt;div class="sign__caption"&amp;gt;
              &amp;lt;p&amp;gt;Signin for home delivery service&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="user_id"&amp;gt;
              &amp;lt;!-- user id options for username and password --&amp;gt;
              &amp;lt;input type="text" name="Username" placeholder="Username"&amp;gt;
              &amp;lt;input type="password" name="Password" placeholder="Password"&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="checkbox__wrapper"&amp;gt;
              &amp;lt;!-- Input filed for checkbox and forget password --&amp;gt;
              &amp;lt;input type="checkbox" name="checkbox"&amp;gt;
              &amp;lt;label for="checkbox"&amp;gt;stay signed in&amp;lt;/label&amp;gt; 
              &amp;lt;a href="#"&amp;gt;Forget Password?&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="btn__wrapper"&amp;gt;
              &amp;lt;!-- Sign in button --&amp;gt;
              &amp;lt;button class="btn__signin"&amp;gt;sign in&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="signup__option"&amp;gt;
              &amp;lt;!-- Sign up opption for new users --&amp;gt;
              &amp;lt;p&amp;gt;Don't have an accout yet? &amp;lt;a href="#"&amp;gt;Sign Up!&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/section&amp;gt;
        &amp;lt;/section&amp;gt;
      &amp;lt;/main&amp;gt;
    &amp;lt;/main&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;CSS:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*, *::after, *::before {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.site__container {
    width: 100vw;
    height: 100vh;
}

.hero__images {
    height: 100%;
    /* background-image: url("Screenshot\ \(209\).png"); */
    background-image: url("https://i.postimg.cc/NfX1S37K/delivery-man.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    /* background-color: aqua; */
}

.card__wrapper {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card__forms {
    display: flex;
    justify-content: center;
    width: 400px;
    height: 400px;
    background-color: rgb(1, 32, 32, 0.4);
    border-radius: 0.5rem;
    box-shadow: 3.5px 3.5px 4px 2px rgba(0, 0, 0, 0.3);
    /* border: 1px solid rgb(89, 250, 156); */
    border-top: 2px solid rgb(89, 250, 156);
    border-bottom: 2px solid rgb(89, 250, 156);
}

.site__logo {
    width: 40px;
    padding: 4px;
    margin: 2.0rem 5rem;
    text-align: center;
    border-radius: 4px;
    font-size: x-large;
    font-weight: bolder;
    font-family: 'Trebuchet MS', sans-serif;
    background-color: rgb(89, 250, 156);
    color: rgb(1, 32, 32);
    border-radius: 50%;
    cursor: default;
}

.sign__caption p {
    color: white;
    font-family: calibri;
    font-style: italic;
    text-transform: lowercase;
    margin-bottom: 1.5rem;
}

.user_id input {
    width: 100%;
    display: block;
    outline: none;
    border: 0;
    padding: 1rem;
    border-radius: 20px;
    margin: 0.8rem 0;
    color: rgb(1, 32, 32);
}

.user_id input::placeholder{
    color: rgb(1, 32, 32);
}

.user_id input:active {
    outline: 2px solid rgb(89, 250, 156);
}


.checkbox__wrapper label {
        color: white;
        font-family: calibri;
        text-transform: lowercase;
}

.checkbox__wrapper a {
        color: rgb(89, 250, 156);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: italic;
}

.checkbox__wrapper a:hover {
        color: rgb(255, 255, 255);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: normal;
}

.btn__wrapper button {
    width: 100%;
    border: none;
    padding: 1rem;
    border-radius: 20px;
    text-transform: uppercase;
    font-weight: bolder;
    margin: 0.8rem 0;
    color: rgb(1, 32, 32);
}

.btn__wrapper button:hover {
    background-color: rgb(89, 250, 156); 
    color: white;
    transition: all 0.5s ease-in-out;
    cursor: pointer;
}

.signup__option p {
    color: white;
        font-family: calibri;
        text-transform: lowercase;
}
.signup__option a {
        color: rgb(89, 250, 156);
        font-family: calibri;
        text-transform: lowercase;
        text-decoration: none;
        font-style: italic;
}

.signup__option a:hover {
    color: rgb(255, 255, 255);
    font-family: calibri;
    text-transform: lowercase;
    text-decoration: none;
    font-style: normal;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Test your sign-ups forms on 3000+ real devices. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;Try LambdaTest Now&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;Do you want to brush up on your CSS properties? Check out our &lt;a href="https://www.lambdatest.com/learning-hub/css-cheat-sheet?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;CSS Cheat Sheet Tutorial.&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Testing CSS Forms with LT Browser
&lt;/h2&gt;

&lt;p&gt;Now that we have completed our project on styling CSS Forms, it’s usually a best practice to test our website or web app before deployment (before we upload it to a server).&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; tools such as LambdaTest enables us to perform &lt;a href="https://www.lambdatest.com/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;web testing&lt;/a&gt; on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm &lt;/a&gt;of 3000+ real browsers, operating systems and devices ranging from mobile, tablets, and desktops. This helps us &lt;a href="https://www.lambdatest.com/responsive-test-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test website for responsiveness&lt;/a&gt; on different operating systems across multiple browsers.&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;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/usability-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Usability Testing&lt;/a&gt;: A Comprehensive Guide With Examples And Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;LambdaTest’s &lt;a href="https://www.lambdatest.com/mobile-friendly-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile-friendly testing tool&lt;/a&gt; saves you time and money. &lt;a href="https://www.lambdatest.com/lt-browser?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LT Browser&lt;/a&gt; comes with 50+ pre-installed mobile-friendly viewports and advanced developer tools for creating a mobile app.&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;&lt;strong&gt;&lt;em&gt;Check this out: Most Comprehensive &lt;a href="https://www.lambdatest.com/blog/selenium-ide-what-is-it-why-is-it-must-for-every-qa/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium IDE&lt;/a&gt; Tutorial&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Follow the below steps to launch LT Browser for &lt;a href="https://www.lambdatest.com/learning-hub/responsive-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;responsive testing&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Firstly, launch LT Browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This will open the LT Browser home page, where you have a list of different operating systems pre-installed devices to choose from.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AJu_a6-Mf8NT8JgJk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AJu_a6-Mf8NT8JgJk.png" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- While your LT Browser remains open, copy and paste this link (&lt;a href="https://codepen.io/ocxigin/pen/gOebaWb" rel="noopener noreferrer"&gt;https://codepen.io/ocxigin/pen/gOebaWb&lt;/a&gt;) from the code pen address bar and paste it on the LT Browser address bar and then click on the refresh icon to reload the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AbSNsCOqHyO_fk5w_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AbSNsCOqHyO_fk5w_.png" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the code output from LT Browser, you’ll notice how each device you choose affects how the web form is structured and laid out.&lt;/p&gt;

&lt;p&gt;LT Browser does much more than that. We can also perform debugging by launching the Dev tools, which can be accessed by clicking the debug icon above the device preview tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AOfj7kQ8J-Lyglv4J.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2732%2F0%2AOfj7kQ8J-Lyglv4J.png" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a better understanding of how your site scales on multiple browsers across multiple operating systems, use the pre-installed devices available on your home screen, select and see how your website performs on these devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec19_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Emulator Online&lt;/a&gt;- Test your mobile websites and smartphone apps using our scalable on cloud mobile emulator.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;You have learned &lt;strong&gt;how to style forms using CSS&lt;/strong&gt;. You also learned how to center items using Flexbox, using transition on buttons, apply background images and how to cross text your website or web app using LambdaTest.&lt;/p&gt;

&lt;p&gt;Alright! We’ve come to the end of this tutorial.&lt;br&gt;
Thanks for taking your time to read this article to completion. Feel free to ask questions. I’ll gladly reply. You can find me on Twitter and other social media @ocxigin.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cheers
&lt;/h1&gt;

</description>
      <category>css</category>
      <category>testing</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
