<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Keep Coding</title>
    <description>The latest articles on DEV Community by Keep Coding (@keepcoding).</description>
    <link>https://dev.to/keepcoding</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%2F182400%2Fc52b6b2a-806a-46c5-862d-896aca467226.png</url>
      <title>DEV Community: Keep Coding</title>
      <link>https://dev.to/keepcoding</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/keepcoding"/>
    <language>en</language>
    <item>
      <title>How to implement Consent Mode for free?</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Thu, 19 Sep 2024 08:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/how-to-implement-consent-mode-for-free-4mfn</link>
      <guid>https://dev.to/keepcoding/how-to-implement-consent-mode-for-free-4mfn</guid>
      <description>&lt;p&gt;At least once a month, I meet with a couple of Heads of Marketing from other companies. We exchange our experiences, discuss interesting tools and the industry in general.&lt;/p&gt;

&lt;p&gt;During our February 2024 meeting, one subject dominated, and almost everyone expressed similar sentiment towards it.&lt;/p&gt;

&lt;p&gt;Google's Consent Mode update is an Armageddon! 💥&lt;/p&gt;

&lt;p&gt;It seemed as if all plans were scrapped, all tasks rearranged, and teams of analysts and marketers delegated to learn about the "Consent Mode v2" and implement it.&lt;/p&gt;

&lt;p&gt;All because of a &lt;em&gt;disturbing looking alert in Google Analytics&lt;/em&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furpdqj3kxkiiz47wypvo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furpdqj3kxkiiz47wypvo.png" alt="Image description" width="800" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And an even &lt;em&gt;more disturbing one in Google Ads&lt;/em&gt;:&lt;/p&gt;

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

&lt;p&gt;If you check the searches for "Google Consent Mode" or "Consent Mode v2" on Google Trends, you will get a clear picture of &lt;strong&gt;how big of a deal this update was to marketers online&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5olnbsdst6v44lvdhtv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5olnbsdst6v44lvdhtv.png" alt="Image description" width="800" height="468"&gt;&lt;/a&gt;&lt;br&gt;
Google Consent Mode search term chart on Google Trends - it peaks to 100 in March&lt;/p&gt;

&lt;p&gt;In the rest of the article below, you will find a very long instruction on how to implement Consent Mode, using just Google Tag Manager &amp;amp; some custom scripts.&lt;/p&gt;

&lt;p&gt;The end result is your own cookie banner, over which you have full control with no reoccurring fees, no external banner providers, and no additional plugins.&lt;/p&gt;

&lt;p&gt;The guide is very detailed and constructed in a step-by-step manner, but if you don't want to do it yourself, or you need a more customized implementation of the cookie banner I recommend you to &lt;a href="https://calendly.com/cognivis/implement-consent-mode" rel="noopener noreferrer"&gt;schedule a call&lt;/a&gt;📞 with our team.&lt;/p&gt;
&lt;h2&gt;
  
  
  What happens if you don't implement Consent Mode?
&lt;/h2&gt;

&lt;p&gt;So, why did everyone panic? 🤔&lt;/p&gt;

&lt;p&gt;Here is the &lt;strong&gt;list of consequences of not implementing Consent Mode&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You will lose Google Analytics data 📉 from all EEA countries (which are all countries in the EU + a few other highly-converting markets such as Norway)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will lose crucial Google Ads features 🚫 such as remarketing, lookalike audiences, conversion modeling &amp;amp; other, for those countries&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You may get fined 💸 if you are using other cookie-based trackers (non Google) like Meta Pixel, Microsoft Clarity, or even something as simple as ReCAPTCHA and you don't implement Consent Mode or an alternative solution for managing consent for these trackers - you may simply break the law and get fined.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, these consequences are serious.&lt;/p&gt;
&lt;h2&gt;
  
  
  How much does a cookie banner cost?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;So, everyone panicked.&lt;/strong&gt; They needed to comply with the Consent Mode quickly. Also, the documentation regarding consent mode was not an instruction, but a collection of articles written in dense paragraphs and with multiple links to other pages and legislation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The obvious solution was to purchase a Consent Mode compliant cookie banner.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google even nudges the marketers towards this, recommending a list of Google Certified CMPs* in the documentation multiple times.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;*CMP stands for "Consent Management Platform"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The monthly prices for a CMP cookie banner in the US 💸 range from $10 to $350 💸. Prices can go even higher depending on the scale of your website.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Also, most of these platforms, have pricing dependent on the number of subpages of your website - &lt;em&gt;so the more pages you have, the more you pay&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Can you implement Consent Mode without a CMP?
&lt;/h2&gt;

&lt;p&gt;For most small businesses the short answer is &lt;strong&gt;yes, you can implement Consent Mode for free without using a CMP.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is an exception.&lt;/p&gt;

&lt;p&gt;If you are an "ad publisher", you have to use a CMP. In other words, &lt;strong&gt;if your website is displaying advertising for other products or services on its subpage&lt;/strong&gt;s (most likely via AdSense), you are actually &lt;a href="https://support.google.com/adsense/answer/13554116?hl=en" rel="noopener noreferrer"&gt;required by Google&lt;/a&gt; to use the services of a certified CMP provider.&lt;/p&gt;

&lt;p&gt;But, if you only want to use Google Ads, &lt;strong&gt;to show the advertising for your own products / services&lt;/strong&gt; to users of other websites or via search - &lt;strong&gt;then you don't have to use a CMP&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In that second case 👉 you can easily implement the Consent Mode v2 for free on your own.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a detailed explanation, of how to do it:&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementing a cookie banner via Google Tag Manager
&lt;/h2&gt;

&lt;p&gt;Below, I will show you how to implement a cookie banner on your website.&lt;/p&gt;

&lt;p&gt;The banner will be:&lt;/p&gt;

&lt;p&gt;✅ compliant with &lt;strong&gt;Google Consent Mode v2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ compliant with &lt;strong&gt;GDPR, ePrivacy directive, CCPA&lt;/strong&gt; and a bunch of other regional regulations&lt;/p&gt;

&lt;p&gt;✅ implemented entirely &lt;strong&gt;via Google Tag Manager&lt;/strong&gt; without the need to use any other services&lt;/p&gt;

&lt;p&gt;🎨 fully &lt;strong&gt;customizable&lt;/strong&gt;, and entirely manageable by your own team&lt;/p&gt;

&lt;p&gt;🤑 &lt;strong&gt;free&lt;/strong&gt; - no more monthly payments for a banner!&lt;/p&gt;

&lt;p&gt;We will go through &lt;strong&gt;3 different scenarios&lt;/strong&gt;, from the least, to the most advanced ones.&lt;/p&gt;

&lt;p&gt;These scenarios are as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No banner at all&lt;/strong&gt;: You just want to &lt;strong&gt;unlock Google Ads&lt;/strong&gt; and you don't want to show any kind of banner. In that case, you will simply set the Consent Mode to &lt;strong&gt;denied by default for regions that require consent, and auto-accept in all other regions&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simple, non-intrusive banner&lt;/strong&gt;: You want to show a simple banner with &lt;strong&gt;accept/reject options&lt;/strong&gt;. You will show the users &lt;strong&gt;in the regions that require it&lt;/strong&gt;, a &lt;strong&gt;small, non-intrusive popup&lt;/strong&gt; with options to accept or reject all cookies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Advanced banner:&lt;/strong&gt; You want to show an advanced (but still small) banner with options to manage each consent type separately i.e._ agree to analytics but reject consent for ads personalization_.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But before we jump into these specific cases, let's cover a the parts common for all of them.&lt;/p&gt;
&lt;h2&gt;
  
  
  What countries require consent?
&lt;/h2&gt;

&lt;p&gt;Notice how I mentioned &lt;strong&gt;"regions that require consent"&lt;/strong&gt; instead of simply using the "EEA" abbreviation. That is because, unfortunately, if you would like to be 100% complaint, with all local regulations across the globe🌎 you need to cover a wider range of &lt;em&gt;territories&lt;/em&gt; than just EEA countries.&lt;/p&gt;

&lt;p&gt;In this article, I will aim to provide a &lt;strong&gt;"one-size-fits-all"&lt;/strong&gt; approach, so with every scenario, I will try to show you a setup that fulfils the requirements of as many legislations as possible.&lt;/p&gt;

&lt;p&gt;But you may want to modify it on your own, so here is a list of &lt;strong&gt;specific legislative acts and regions&lt;/strong&gt; you should consider.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://europa.eu/youreurope/business/dealing-with-customers/data-protection/data-protection-gdpr/index_en.htm" rel="noopener noreferrer"&gt;EEA GDPR&lt;/a&gt; (all EEA countries)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ico.org.uk/for-organisations/data-protection-and-the-eu/data-protection-and-the-eu-in-detail/the-uk-gdpr/" rel="noopener noreferrer"&gt;UK GDPR&lt;/a&gt; (United Kingdom)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.fedlex.admin.ch/eli/cc/2022/491/en" rel="noopener noreferrer"&gt;FADP&lt;/a&gt; (Switzerland)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://lgpd-brazil.info/" rel="noopener noreferrer"&gt;LDGP&lt;/a&gt; (Brazil)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://popia.co.za/" rel="noopener noreferrer"&gt;POPIA&lt;/a&gt; (South Africa)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://oag.ca.gov/privacy/ccpa" rel="noopener noreferrer"&gt;CCPA/CPRA&lt;/a&gt; (US - California)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://coag.gov/resources/colorado-privacy-act/" rel="noopener noreferrer"&gt;CPA&lt;/a&gt; (US - Colorado)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://portal.ct.gov/ag/sections/privacy/the-connecticut-data-privacy-act" rel="noopener noreferrer"&gt;CTDPA&lt;/a&gt; (US - Connecticut)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dcp.utah.gov/ucpa/" rel="noopener noreferrer"&gt;UCPA&lt;/a&gt; (US - Utah)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://law.lis.virginia.gov/vacodepopularnames/virginia-consumer-protection-act/" rel="noopener noreferrer"&gt;VCDPA&lt;/a&gt; (US - Virginia)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list will be important &lt;strong&gt;in the later steps of this article, when we will use the codes of these regions&lt;/strong&gt;, to setup consent mode settings.&lt;/p&gt;
&lt;h2&gt;
  
  
  Consent types &amp;amp; "default consent"
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;For all 3 scenarios we have to start with setting up the default consent tag.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Google Tag Manager (GTM), &lt;a href="https://developers.google.com/tag-platform/security/guides/consent?hl=en&amp;amp;consentmode=advanced#default-consent" rel="noopener noreferrer"&gt;default consent&lt;/a&gt; refers to the initial state a tag is set to, before any other events on the website occur.&lt;/p&gt;

&lt;p&gt;Google needs to receive a "consent signal" from your website for each consent type. The signal value must be either "&lt;strong&gt;denied&lt;/strong&gt;" or "&lt;strong&gt;granted&lt;/strong&gt;" for all required consent types.&lt;/p&gt;
&lt;h2&gt;
  
  
  Checking consent signals
&lt;/h2&gt;

&lt;p&gt;You can easily &lt;strong&gt;check if your website is sending "consent signals"&lt;/strong&gt; with events in the &lt;strong&gt;GTM debugger&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Run a &lt;a href="https://support.google.com/tagmanager/answer/6107056?hl=en" rel="noopener noreferrer"&gt;Preview&lt;/a&gt; of your site&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to "Consent" tab - check all events&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you don't have the Consent Mode configured yet, you will get an information that "Default consent state has not been set yet"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feajurk3aslrp710vf0h9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feajurk3aslrp710vf0h9.png" alt="Image description" width="800" height="137"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Consent tab in Google Tag Manager debugger mode&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Consent types
&lt;/h2&gt;

&lt;p&gt;Google provides us with the following &lt;a href="https://developers.google.com/tag-platform/tag-manager/templates/consent-apis?hl=en#consent-introduction" rel="noopener noreferrer"&gt;Consent Types&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ad_storage&lt;/strong&gt;: Enables storage, such as cookies, related to advertising.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ad_user_data&lt;/strong&gt;: Sets consent for sending user data to Google for online advertising purposes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ad_personalization&lt;/strong&gt;: Sets consent for personalized advertising.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;analytics_storage&lt;/strong&gt;: Enables storage, such as cookies, related to analytics (for example, visit duration).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;functionality_storage&lt;/strong&gt;: Enables storage that supports the functionality of the website or app such as language settings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;personalization_storage&lt;/strong&gt;: Enables storage related to personalization such as video recommendations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;security_storage&lt;/strong&gt;: Enables storage related to security such as authentication functionality, fraud prevention, and other user protection&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are simply &lt;strong&gt;different types of cookies&lt;/strong&gt; you store on your website. Most legislations like GDPR &lt;strong&gt;allow for auto-granting "strictly necessary cookies"&lt;/strong&gt; even without consent.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="https://gdpr.eu/cookies/#:~:text=Purpose-,Strictly%20necessary%20cookies,-%E2%80%94%20These%20cookies%20are" rel="noopener noreferrer"&gt;exact wording of the GDPR&lt;/a&gt;. And regarding the cookie compliance &lt;a href="https://gdpr.eu/cookies/#:~:text=Receive%20users%E2%80%99%20consent%20before%20you%20use%20any%20cookies%20except%20strictly%20necessary%20cookies." rel="noopener noreferrer"&gt;this is the most important rule&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Now... it's UP TO YOU 👇 to decide which of the cookies you add to your website are strictly necessary for your services.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the next steps, I will set default consent types, based on the "safest", most conservative assumption, that none cookies are essential for your service, but you may want to customize that by, for example - granting the "security_storage" by default.&lt;/p&gt;
&lt;h2&gt;
  
  
  Uploading a free consent template to Google Tag Manager
&lt;/h2&gt;

&lt;p&gt;So, how do we send the "consent signal" to Google? 🤔&lt;/p&gt;

&lt;p&gt;Your CMP will do this automatically, after you implement it. You can also ask a developer to implement it with &lt;a href="https://developers.google.com/tag-platform/security/guides/consent?hl=en&amp;amp;consentmode=advanced" rel="noopener noreferrer"&gt;these docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Luckily, the awesome &lt;a href="https://www.linkedin.com/in/mikebrickl/?lipi=urn%3Ali%3Apage%3Ad_flagship3_pulse_read%3BQ6ODPulYQxyE049FJNfsRQ%3D%3D" rel="noopener noreferrer"&gt;Michael Brickl&lt;/a&gt; from Google, created a template, that we can &lt;strong&gt;easily upload to Google Tag Manager ourselves&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/googleanalytics/gtm-consent-mode-examples/tree/main" rel="noopener noreferrer"&gt;Visit this repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Code" --&amp;gt; "Download ZIP"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fncor4a7rqb4sg3rcpl3u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fncor4a7rqb4sg3rcpl3u.png" alt="Image description" width="800" height="403"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;implement consent mode for free - download tag template&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Extract all files from the .zip folder&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In &lt;a href="https://tagmanager.google.com/" rel="noopener noreferrer"&gt;Google Tag Manager&lt;/a&gt;, go to the Templates section on the left side of the screen&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "New"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbr8ffhvve0ursu1hi9i7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbr8ffhvve0ursu1hi9i7.png" alt="Image description" width="800" height="244"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;implement consent mode for free - creating new consent template&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Template Editor&lt;/strong&gt; that will pop up, click on the three dots in the upper right corner and click "&lt;strong&gt;Import&lt;/strong&gt;"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;import Consent Mode free template&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Locate the file with an &lt;strong&gt;.tpl&lt;/strong&gt; extension in the folder you extracted&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flh7d31k41cze96ej7cpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flh7d31k41cze96ej7cpb.png" alt="Image description" width="800" height="243"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;TPL template for GTM Consent Mode Tag&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After it loads, name the template something like "Consent Mode" &amp;amp; click "Save"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87c87y1k64gv4vdibb09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87c87y1k64gv4vdibb09.png" alt="Image description" width="800" height="250"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Save Consent Mode free template&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Done! You will see a "Template saved" notification at the bottom of your screen.&lt;/p&gt;

&lt;p&gt;We will configure this template in various ways in all 3 scenarios below.&lt;/p&gt;

&lt;p&gt;Now let's jump into the first scenario - running a website without any kind of cookie banner.&lt;/p&gt;
&lt;h2&gt;
  
  
  Case 1: Running a website without a cookie banner
&lt;/h2&gt;

&lt;p&gt;First of all, you can still use some Google Ads features, and Google Analytics, &lt;strong&gt;without implementing any kind of banner&lt;/strong&gt; on your website.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;you still have to comply with the Consent Mode&lt;/strong&gt; to make sure your Google Ads account gets 🔓 unlocked. So, even if you are not interested in analytics and retargeting for EEA users but want to run ads in the EEA &lt;a href="https://support.google.com/google-ads/answer/14505993?hl=en" rel="noopener noreferrer"&gt;you have to comply&lt;/a&gt;. Consent management &lt;a href="https://cookie-script.com/blog/google-consent-mode-v2-advertisement#:~:text=Consent%20management%20is%20required%20to,Consent%20before%20using%20Google%20Ads." rel="noopener noreferrer"&gt;is required&lt;/a&gt; to serve Google Ads.&lt;/p&gt;

&lt;p&gt;For this to work you will have to:&lt;/p&gt;

&lt;p&gt;❌ *&lt;em&gt;Auto-reject *&lt;/em&gt; all kinds of &lt;a href="https://developers.google.com/tag-platform/security/concepts/consent-mode?hl=en#consent-types" rel="noopener noreferrer"&gt;Google required Consent Types&lt;/a&gt;, in all of the regions that require consent for cookie-tracking&lt;/p&gt;

&lt;p&gt;✔️&lt;strong&gt;Auto-accept&lt;/strong&gt; in all other regions&lt;/p&gt;

&lt;p&gt;The consequences of that will be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You won't be able to use any kind of retargeting features for regions that require consent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You won't see any GA4 analytics for regions that require consent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You will be able to run Google Ad campaign types without retargeting in the regions that require consent, and all other campaign types in countries that don't require consent&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, how we can do that?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;Google Tag Manager&lt;/strong&gt; go to your &lt;strong&gt;Tags&lt;/strong&gt; &amp;amp; click "&lt;strong&gt;New&lt;/strong&gt;"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9yhhv84im22oduxre149.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9yhhv84im22oduxre149.png" alt="Image description" width="800" height="234"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Adding a new tag in Google Tag Manager&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;Tag Configuration&lt;/strong&gt; choose the template we uploaded in the previous step&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flnilkn1xmaqn1ctq0szk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flnilkn1xmaqn1ctq0szk.png" alt="Image description" width="800" height="434"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Choosing Consent Mode tag with a free template&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;Consent Command&lt;/strong&gt; choose "&lt;strong&gt;Default Command&lt;/strong&gt;"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwm6r3ehhe50yqu88c92b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwm6r3ehhe50yqu88c92b.png" alt="Image description" width="800" height="550"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Setting up default command in the Consent Mode tag&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now we will &lt;strong&gt;specify the default settings for the regions we want to auto-reject&lt;/strong&gt;. We will include all of the regions that are covered by the legislation I listed in the "&lt;strong&gt;What countries require consent?&lt;/strong&gt;" section.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will need to use a list of **2-letter ISO **codes for each country separated by commas &amp;amp; some region specific codes for the US states.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Luckily for you, I already made that list.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Below you will find the list for all the regions, in all legislations I mentioned above, if you want to customize it, simply add or remove some regional codes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copy this list:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IS, IE, IT, LV, LI, LT, LU, MT, NL, NO, PL, PT, RO, SK, SI, ES, SE, GB, CH, BR, ZA, US-CA, US-CO, US-CT, US-UT, US-VA&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on "&lt;strong&gt;Add Row&lt;/strong&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Paste the list into the "&lt;strong&gt;Region&lt;/strong&gt;" input&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set all of the consent types to "&lt;strong&gt;Denied&lt;/strong&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then click "&lt;strong&gt;Add&lt;/strong&gt;" to add the default rule for all of these countries. The UI in GTM is likely to get messy after you add this - don't worry, it doesn't look pretty but it works.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91zpqnymglvqqzkxnx3v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91zpqnymglvqqzkxnx3v.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Setting default consent for specific countries to Denied&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Great! You added a specific rule for all of the countries with restrictive privacy regulations. Now let's cover the rest of them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;To &lt;strong&gt;auto-accept&lt;/strong&gt; consent in &lt;strong&gt;all remaining regions&lt;/strong&gt; you simply need to click "&lt;strong&gt;Add row&lt;/strong&gt;" again&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leave the "Region" input empty this time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set all of the consent types to "Granted" this time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Add" again.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This setting (&lt;em&gt;"Granted" consent types&lt;/em&gt;), with an empty "Region" input, will apply to all of the regions that aren't specified in the other Region settings row.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyyo4tytbzq9kculz1ud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyyo4tytbzq9kculz1ud.png" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Setting default consent for all non-specified countries to Granted&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Name your Tag something like "Default Consent"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set the trigger to "Initialization - All pages"&lt;/strong&gt; 🚨 it has to be the first tag to fire on every page&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgllj9iyxu4b9ngd1vty9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgllj9iyxu4b9ngd1vty9.png" alt="Image description" width="800" height="399"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Setting the trigger for the consent tag&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Save your tag&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that's it! You have implemented Consent Mode without a banner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consent will now be auto-rejected in every region that requires a banner and auto-accepted in every other country.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can end here, if you don't care about data from the countries that require a banner, and you don't want to implement it. Otherwise - keep reading!&lt;/p&gt;
&lt;h2&gt;
  
  
  Case 2: Small, non-intrusive cookie banner
&lt;/h2&gt;

&lt;p&gt;Now, let's learn how we can easily show a cookie banner to the countries that actually require it, so that &lt;strong&gt;the user has an option to accept our analytics &amp;amp; ad retargeting efforts&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prepare the setup from the previous section&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since we want to show the banner only for the countries that actually require it, most of the settings in the previous section ("&lt;em&gt;Running a website without a cookie banner&lt;/em&gt;") will stay the same.&lt;/p&gt;

&lt;p&gt;Make sure to 🚨 &lt;strong&gt;start by doing all of the instructions from the previous section.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the instructions below, I will show you how to add the simple banner &amp;amp; adjust the previous setup to it, so that it works with the banner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create the banner Tag, consent Variables &amp;amp; the Trigger&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a new &lt;strong&gt;Tag&lt;/strong&gt; &amp;amp; name it something like "Simple Cookie Banner"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In "Tag configuration" choose the "&lt;strong&gt;Custom HTML&lt;/strong&gt;" option&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl190sn8vtx6sfp07bope.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl190sn8vtx6sfp07bope.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Create a custom HTML tag for the banner&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add banner HTML &amp;amp; banner styles.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Below, I've prepared a &lt;strong&gt;ready-to-use, copy &amp;amp; paste template&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want to customize the banner - you should be able to easily do it with just a bit of knowledge of CSS and HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A few words on how the banner works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Displays a Banner with Two Options&lt;/strong&gt;: A small popup appears at the bottom-right corner of the screen, informing visitors about the use of cookies. Visitors can choose to either "Accept" or "Reject" all cookies by clicking the respective buttons. You can 👁️ preview the demo here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sets Cookie Preferences&lt;/strong&gt;: Depending on the visitor's choice, the banner sets cookies to either "granted" or "denied" to manage their consent. The preferences are saved and applied across the website.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The preferences are saved in cookies with names matching the Consent Type names (&lt;em&gt;i.e. ad_storage&lt;/em&gt;) - we will use that in later steps.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You are welcome to design your own banner - just make sure its able to set the consent cookies like in the example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copy the code below &amp;amp; paste it directly into the tag&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;style&amp;gt;
 /*Fade modal in*/
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* Adjusted fade-out animation to use opacity and visibility */
#accept_cookies_modal.fade-out {
  animation: fadeOutAnimation 0.5s ease-out forwards;
}
@keyframes fadeOutAnimation {
  to {
    opacity: 0;
    transform: translateX(50px);
    visibility: hidden; /* Add visibility to the keyframes */
    display: none; /* Hide the modal after animation */
  }
}
/* Non-invasive modal styling */
#accept_cookies_modal {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 1050; /* Ensure it's above other content */
  width: auto; /* Auto width based on content, can adjust as needed */
  max-width: 90%; /* Ensuring it doesn't stretch too wide on small screens */
  visibility: visible; /* Always visible when added to the page */
  opacity: 1; /* Fully opaque */
  transition: opacity 0.3s ease; /* Smooth transition for opacity */
  padding: 10px; /* Padding around the modal for shadows*/
  font-family: roboto, sans-serif; /* Font family for modal */
  animation: fadeInRight 0.5s ease-out forwards; /* Fade in animation */
}
/* Ensuring modal is responsive */
@media (min-width: 768px) {
  #accept_cookies_modal .modal-dialog {
    max-width: 300px; /* Adjust based on preference */
  }
}
#accept_cookies_modal .modal-content {
  background-color: #fff; /* Background color */
  border: 1px solid #ddd; /* Border color */
  border-radius: 0.5rem; /* Rounded corners */
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.25),
    0 3px 10px 5px rgba(0, 0, 0, 0.05) !important;
  overflow: hidden; /* Ensures no content spills outside */
}
#accept_cookies_modal .modal-body {
  padding: 15px; /* Padding around the text */
  font-size: 14px; /* Adjust text size as needed */
  color: #4f4f4f; /* Text color */
}
#accept_cookies_modal .modal-footer {
  text-align: right; /* Align buttons to the right */
  padding: 10px 15px; /* Padding inside footer */
  border-top: 2.5px solid hsla(0, 0%, 87%, 0.911); /* Separator from content */
}
/* Button styling */
#accept_cookies_modal .btn {
  padding-right: 1.5rem; /* Right padding for button */
  padding-left: 1.5rem; /* Left padding for button */
  padding-top: 0.375rem; /* Top padding for button */
  padding-bottom: 0.375rem; /* Bottom padding for button */
  font-size: 0.75rem; /* Button font size */
  font-weight: 500; /* Normal font weight for button */
  font-family: inherit; /* Inherit font family from parent */
  line-height: 1.42857143; /* Line height for text inside button */
  border-radius: 0.25rem; /* Rounded corners for buttons */
  cursor: pointer; /* Change cursor to pointer on hover */
  border: 1px solid transparent; /* No border by default */
  transition: background-color 0.2s ease; /* Smooth background color transition */
  text-transform: uppercase; /* Uppercase text */
}
#accept_cookies_modal .btn-primary {
  color: #fff;
  background-color: #3b71ca;
  box-shadow: rgb(56, 107, 192) 0px 4px 9px -4px;
}
#accept_cookies_modal .btn-tertiary {
  color: #3b71ca;
  background-color: #fff;
  box-shadow: none;
}
#accept_cookies_modal .btn-primary:hover,
.btn-primary:focus {
  background-color: #386bc0; /* Darken background color slightly for primary button */
}
#accept_cookies_modal .btn-tertiary:hover,
.btn-tertiary:focus {
  background-color: #f2f2f2; /* Lighten background color slightly for tertiary button */
}
/* Maintain focus styles for accessibility */
#accept_cookies_modal .btn:focus,
.btn-primary:focus,
.btn-tertiary:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); /* Adding a focus ring for accessibility */
}
#accept_cookies_modal a {
  color: #4f4f4f; /* Text color */
  text-decoration: underline; /* Underline links */
  transition: color 0.2s ease; /* Smooth color transition on hover */
}
&amp;lt;/style&amp;gt;

&amp;lt;!--Accept cookies modal HTML structure--&amp;gt;
    &amp;lt;div class="modal-external" id="accept_cookies_modal" role="dialog"&amp;gt;
      &amp;lt;div class="modal-dialog"&amp;gt;
        &amp;lt;div class="modal-content"&amp;gt;
          &amp;lt;div class="modal-body"&amp;gt;
            We use cookies to enhance your browsing experience, analyze traffic,
            serve ads, and personalize content in accordance with our
            &amp;lt;a href="/privacy-policy/"&amp;gt;Privacy Policy&amp;lt;/a&amp;gt;. Click 'Accept' to
            consent to our use of cookies.
          &amp;lt;/div&amp;gt;
          &amp;lt;div class="modal-footer"&amp;gt;
            &amp;lt;button class="btn btn-tertiary" 
            name="reject_all_cookies"&amp;gt;
              reject
            &amp;lt;/button&amp;gt;
            &amp;lt;button
              class="btn btn-primary"
              name="accept_all_cookies"
              id="accept-all-cookies"
            &amp;gt;
              ACCEPT
            &amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;!--//Accept cookies modal HTML structure--&amp;gt;


&amp;lt;!--Scripts--&amp;gt;
&amp;lt;script&amp;gt;
  // Modal dismissal function: fades out and hides the modal
  function dismissModal() {
    var modal = document.getElementById("accept_cookies_modal");
    if (modal) {
      modal.classList.add("fade-out"); // Initiates fade-out animation

      // Listens for the end of the animation to fully hide the modal
      modal.addEventListener("animationend", function () {
        modal.style.opacity = "0"; // Ensures the modal is invisible
        modal.style.display = "none"; // Fully hides the modal
      }, { once: true }); // Ensures the listener is removed after execution
    }
  }

  // Sets all specified cookies to 'granted'
  function setAllCookiesToGranted() {
    var cookies = ["ad_storage", "ad_user_data", "ad_personalization",  "analytics_storage", "personalization_storage","security_storage"];
    for (var i = 0; i &amp;lt; cookies.length; i++) {
      document.cookie = cookies[i] + "=granted; Secure; Path=/; SameSite=Lax; max-age=" + 60 * 60 * 24 * 400;
    }
  }

  // Sets all specified cookies to 'denied'
  function setAllCookiesToDenied() {
    var cookies = ["ad_storage", "ad_user_data", "ad_personalization",  "analytics_storage", "personalization_storage","security_storage"];
    for (var i = 0; i &amp;lt; cookies.length; i++) {
      document.cookie = cookies[i] + "=denied; Secure; Path=/; SameSite=Lax; max-age=" + 60 * 60 * 24 * 400;
    }
  }

  // Attaches event listeners to "Accept All Cookies" buttons
  var acceptAllCookiesButtons = document.querySelectorAll("button[name='accept_all_cookies']");
  for (var i = 0; i &amp;lt; acceptAllCookiesButtons.length; i++) {
    acceptAllCookiesButtons[i].addEventListener("click", function () {
      setAllCookiesToGranted();
      dismissModal();
      console.log("All cookies set to 'granted' via the accept all cookies button.");
    });
  }

  // Attaches event listeners to "Reject All Cookies" buttons
  var rejectAllCookiesButtons = document.querySelectorAll("button[name='reject_all_cookies']");
  for (var i = 0; i &amp;lt; rejectAllCookiesButtons.length; i++) {
    rejectAllCookiesButtons[i].addEventListener("click", function () {
      setAllCookiesToDenied();
      dismissModal();
      console.log("All cookies set to 'denied' via the reject all cookies button.");
    });
  }
&amp;lt;/script&amp;gt;

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save the tag (leave the trigger empty for now)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This banner will create a first-party cookie on your website for each consent type. When the user clicks "Accept" all of these cookies will have a "granted" value, and when he clicks "Denied" all of the cookies will have a "denied" value.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqwnbhdkcbtlfwd6xhnv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqwnbhdkcbtlfwd6xhnv.png" alt="Image description" width="800" height="232"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;consent cookie values&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In order for you to use the value of these consent types in Google Tag Manager you need to access them with a GTM variable.&lt;/p&gt;

&lt;p&gt;So you need to &lt;strong&gt;create a new GTM variable for each consent type&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We will start with "analytics_storage".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fne74z1wjli37xa8tau6j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fne74z1wjli37xa8tau6j.png" alt="Image description" width="800" height="306"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;GTM variables&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose "&lt;strong&gt;1st party cookie&lt;/strong&gt;" as your variable type&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81d41yj8wutlq8t8a8cs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81d41yj8wutlq8t8a8cs.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;1st party cookie - variable for consent mode implementation&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Name your variable, I recommend using the name of the consent type, in this example "&lt;em&gt;analytics_storage&lt;/em&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the cookie name input, paste the name of the consent type, in that case its "&lt;em&gt;analytics_storage&lt;/em&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the "&lt;strong&gt;Format Value&lt;/strong&gt;" settings set "&lt;strong&gt;Convert undefined to - denied&lt;/strong&gt;" so that the consent is denied by default, before the cookie gets created &amp;amp; granted, when the user clicks the banner.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ct15e307r7pkhy1c83h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ct15e307r7pkhy1c83h.png" alt="Image description" width="800" height="401"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Setup analytics_storage consent variable&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save the variable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🔁&lt;strong&gt;Repeat the process for all other consent types&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should end up with &lt;strong&gt;7 variables, one for each consent type&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjpw71sm003tgfux1v0j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjpw71sm003tgfux1v0j.png" alt="Image description" width="800" height="210"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;consent type variables&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go back to the &lt;strong&gt;Default Consent&lt;/strong&gt; tag, that you created in the previous section.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Click "&lt;strong&gt;Edit&lt;/strong&gt;" on the row, with the countries that require a banner.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;For each consent type, change the setting from "Denied" to the corresponding variable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the tag&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lhqxnd509q27xd2yx84.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lhqxnd509q27xd2yx84.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;consent type variables used for the consent settings in the default consent tag&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now, create a new Trigger&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjbhog5re6ref1sq9tcsv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjbhog5re6ref1sq9tcsv.png" alt="Image description" width="800" height="220"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;create a new trigger for the cookie banner&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Name it something like "Simple Cookie Banner- trigger"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the trigger configuration to "Window Loaded"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the trigger conditions so that it fires only when the "analytics_storage" variable is set to "denied"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the trigger&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28w26k9s7v1osd3qb7zq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28w26k9s7v1osd3qb7zq.png" alt="Image description" width="800" height="330"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;setting up the cookie banner trigger&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add this trigger to your consent banner&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;adding the trigger to the consent banner&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Overwrite analytics cookie for non-restrictive countries&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we will add &lt;strong&gt;another Tag&lt;/strong&gt;, that will make sure that the banner doesn't show up in the countries that it shouldn't show up in.&lt;/p&gt;

&lt;p&gt;Create &lt;strong&gt;another custom HTML Tag&lt;/strong&gt;, name it something like "&lt;strong&gt;Overwrite analytics cookie&lt;/strong&gt;" and paste the code below into it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    // Sets all specified cookies to 'granted'
  function setChosenCookieToGranted() {
    var cookies = ["analytics_storage"];
    for (var i = 0; i &amp;lt; cookies.length; i++) {
      document.cookie = cookies[i] + "=granted; Secure; Path=/; SameSite=Lax; max-age=" + 60 * 60 * 24 * 400;
    }
  }  
  setChosenCookieToGranted();
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;strong&gt;Advanced Settings&lt;/strong&gt; for this tag, select "&lt;strong&gt;Require additional consent for tag to fire&lt;/strong&gt;" and input "&lt;strong&gt;analytics_storage&lt;/strong&gt;" into the input field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the trigger for this tag to "All Pages"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0onoyy8blwx8h1qo7nh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0onoyy8blwx8h1qo7nh.png" alt="Image description" width="800" height="677"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Tag for overwriting the analytics_storage&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;With the setup above, we already have a banner, that will write the Consent status to the cookies on the site, and the status for each new pageview will be sourced from these cookies.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The issue is, that on the first pageview, all Consent types will be set to denied, and they will get updated only after the page is refreshed or new page is visited.&lt;/p&gt;

&lt;p&gt;So the last thing you have to do, is &lt;strong&gt;making sure that the Consent status also gets updated, on the initial pageview, when the user clicks "Accept"&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a trigger, based on the "Accept" button ID&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the template above, the ID was "accept-all-cookies".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuum58u0uhyo14nmrpwih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuum58u0uhyo14nmrpwih.png" alt="Image description" width="800" height="192"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;accept all cookies trigger&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create an "Update command" tag&lt;/strong&gt; with all cookies granted &amp;amp; trigger it using this trigger.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the other option of the consent template we uploaded to our GTM instance.&lt;/p&gt;

&lt;p&gt;Simply set all the consent types here to "Granted" and connect it with the trigger you created in the step above.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgeg3xl7ohynulfrsxw7x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgeg3xl7ohynulfrsxw7x.png" alt="Image description" width="800" height="594"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Update Consent Tag Settings&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Real life scenarios
&lt;/h2&gt;

&lt;p&gt;Now, we will take the break from GTM for a minute, to explain &amp;amp; reiterate how exactly will this setup work, up to this point.&lt;/p&gt;

&lt;p&gt;Here is are 2 example scenarios:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1: A user from Germany&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A user from &lt;strong&gt;Germany&lt;/strong&gt; visits our website&lt;/p&gt;

&lt;p&gt;Since the code for &lt;strong&gt;Germany (DE)&lt;/strong&gt; is included in the specific settings in the "Default Consent Tag", his &lt;strong&gt;consent settings&lt;/strong&gt; will automatically be set to "&lt;strong&gt;denied&lt;/strong&gt;"&lt;/p&gt;

&lt;p&gt;The cookies weren't created by the script yet (the user didn't click neither "Accept" nor "Reject") so the &lt;strong&gt;GTM variables&lt;/strong&gt; will default to "&lt;strong&gt;denied&lt;/strong&gt;"&lt;/p&gt;

&lt;p&gt;Since the "analytics_storage" GTM variable is set to "&lt;strong&gt;denied&lt;/strong&gt;", when the Window Loads entirely, &lt;strong&gt;the banner will fire&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The user can then click "Accept" or "Reject" on the banner - this will fire a proper function, that will create the &lt;strong&gt;cookies&lt;/strong&gt; for each consent type and set them accordingly to "granted" or "denied"&lt;/p&gt;

&lt;p&gt;If the user clicked "Accept", the consent settings value will update instantly - via the Update Consent tag&lt;/p&gt;

&lt;p&gt;From now on, every time the user visits another page, the &lt;strong&gt;consent settings value&lt;/strong&gt; will be pulled from the &lt;strong&gt;consent cookies valu&lt;/strong&gt;e - via the Default Consent tag&lt;/p&gt;

&lt;p&gt;If the user hasn't accepted the banner - they will keep seeing it on every new pageview, since the "analytics_storage" cookie is still set to "denied"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2: A user from the United Arab Emirates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A user from the **United Arab Emirates **visits our website&lt;/p&gt;

&lt;p&gt;The AE country code is not included in the specific settings in the "Default Consent Tag," meaning it falls under the general setting where all &lt;strong&gt;consent settings&lt;/strong&gt; are set to "granted" by default.&lt;/p&gt;

&lt;p&gt;Since the &lt;strong&gt;"analytics_storage" consent setting&lt;/strong&gt; is set to "granted" the _&lt;strong&gt;"Overwrite analytics cookie" Tag&lt;/strong&gt; _will fire, and it will create the &lt;strong&gt;"analytics_storage" cookie&lt;/strong&gt; with a "granted" value&lt;/p&gt;

&lt;p&gt;Therefore, the &lt;strong&gt;"analytics_storage" GTM *&lt;em&gt;will not default to "denied" - it will be set to *&lt;/em&gt;"granted"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since the &lt;strong&gt;"analytics_storage" GTM variable&lt;/strong&gt; is set to "&lt;strong&gt;granted&lt;/strong&gt;" the tag with the &lt;strong&gt;banner&lt;/strong&gt; will not fire, and &lt;strong&gt;the user will not see any kind of banner&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Update your Privacy Policy
&lt;/h2&gt;

&lt;p&gt;Notice that, the banner in the example above is linking to the Privacy Policy page.&lt;/p&gt;

&lt;p&gt;The full text of the banner is:&lt;br&gt;
&lt;em&gt;We use cookies to enhance your browsing experience, analyze traffic, serve ads, and personalize content in accordance with our Privacy Policy. Click 'Accept' to consent to our use of cookies.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And the link is simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="/privacy-policy/"&amp;gt;Privacy Policy&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First of all, &lt;strong&gt;make sure to include the link to your own Privacy Policy page in your banner&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Second, since this banner is as minimalistic as possible, there are no detailed explanations for the cookies you use on the website.&lt;/p&gt;

&lt;p&gt;The GDPR does not explicitly mandate that a detailed explanation of each cookie be included within the banner itself. Instead, the regulation focuses on the need for clear and comprehensive information about data processing, including the use of cookies, to be readily available to users.&lt;/p&gt;

&lt;p&gt;In most cases, it should be enough to &lt;strong&gt;thoroughly explain the 3rd party services &amp;amp; cookies your website is using in the Privacy Policy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Make sure to include these explanations in your Privacy Policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Case 3: Advanced cookie banner with consent management
&lt;/h2&gt;

&lt;p&gt;Customizing the banner will require some significant edits to the design &amp;amp; functionality of the banner tag.&lt;/p&gt;

&lt;p&gt;Since the options for customization are basically endless, this is something you have to plan &amp;amp; implement on your own, or if you need assistance I invite you to &lt;a href="https://calendly.com/cognivis/implement-consent-mode" rel="noopener noreferrer"&gt;schedule a call &lt;/a&gt;📞 with our web development team.&lt;/p&gt;

&lt;p&gt;The key point is that the &lt;strong&gt;setup from cases I and II will allow you to easily modify &amp;amp; play with consent types&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Since each consent type is written to a separate cookie, granular management is just a matter of writing a script that will handle each cookie separately.&lt;/p&gt;

&lt;p&gt;Some ideas you can include in your advanced implementation are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enabling granular consent management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might want to give the users the option to manage each consent type separately.&lt;/p&gt;

&lt;p&gt;For example, by including consent toggle switches for each Consent Type, along with its explanation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhqk4oag8pxi0zljkp2ni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhqk4oag8pxi0zljkp2ni.png" alt="Image description" width="760" height="367"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;managing different consent types with toggles&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nudging the user to accept the types of consent you care most about&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most users that don't want to accept the 3rd party cookies on your site, are people sensitive about getting retargeting ads.&lt;/p&gt;

&lt;p&gt;Getting bombarded with ads for sports shoes after just one visit to the manufacturer's website can make some people feel like they are being "stalked". People often reject cookies to avoid that experience.&lt;/p&gt;

&lt;p&gt;But very often, the website owner will care more about analytics then remarketing. And the user will not care about analytics - it's anonymous, and only provides the site owner with some basic stats to improve the UX like scrolling thresholds, average time spent on the page etc.&lt;/p&gt;

&lt;p&gt;So when the user rejects all cookies in one go its a case of "throwing the baby out with the bathwater".&lt;/p&gt;

&lt;p&gt;You can easily avoid it by adding an option to "Reject only the ad-related cookies", to make it easier for the users to reject the trackers they don't want, and accept other tools important for your analytics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqdgeniq082juhznt4zo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqdgeniq082juhznt4zo.png" alt="Image description" width="787" height="257"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;reject ad cookies &amp;amp; accept others&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non intrusive banner = less acceptance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Making the banner small &amp;amp; non-intrusive like in the example above, increases the probability of the user ignoring it, and simply browsing the site without accepting cookies, with the banner in the corner.&lt;/p&gt;

&lt;p&gt;In that case, the scripts dependent on the consent won't load (since they didn't agreed to it).&lt;/p&gt;

&lt;p&gt;You might want to consider making the banner more intrusive in some cases, for example by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;adding backdrop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;making the banner appear in the center of the page, instead of the corner&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;disabling any interactions on the page, until the user clicks an option on the banner (making it intrusive)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Including cookie explanations in the banner&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the case of the simple banner, you need to maintain a description of the 3rd party cookies you load to your website in the Privacy Policy.&lt;/p&gt;

&lt;p&gt;You might want to add them directly to the banner, so that the user doesn't have to visit another page to learn more about the cookies you use.&lt;/p&gt;

&lt;p&gt;In that case, you would need to add tabs, or scrolling to your banner, to make space for more text.&lt;/p&gt;

&lt;h2&gt;
  
  
  A word on "the end of cookies"
&lt;/h2&gt;

&lt;p&gt;Some businesses are actually delaying introducing Consent Mode on their websites, in hopes that it will become irrelevant, when the "cookie apocalypse" comes.&lt;/p&gt;

&lt;p&gt;This is not a wise decision. Here is why:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google is not phasing out 3rd party cookies anymore&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In recent years, the digital marketing world has been buzzing about the potential phasing out of third-party cookies, especially after Google announced plans to eliminate them from its Chrome browser.&lt;/p&gt;

&lt;p&gt;However, after considering the implications and receiving feedback from various stakeholders, &lt;a href="https://privacysandbox.com/news/privacy-sandbox-update/" rel="noopener noreferrer"&gt;Google decided to recall these plans&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For now,** third-party cookies remain a core component of online advertising**, and this delay suggests that they are here to stay for the foreseeable future.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cookie-based tools are still first choice for the marketers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Although alternatives for cookie-less analytics, such as browser-based tracking and privacy-preserving technologies, have emerged, &lt;strong&gt;the marketing community largely prefers the existing cookie-based ecosystem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Most marketers would choose Google Analytics over any other, cookie-less tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some of the advantages of cookie-based platforms are:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;they still the most advanced analytical / advertising / sales tools on the market&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the data for user behavior and advertising performance is much more granular (more detailed)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;implementation of these tools is much easier&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;there is a huge ecosystem of tutorials for tools like GA4 or Microsoft Clarity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;most marketers are already familiar with these systems&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Its telling how often you will stumble upon a cookie banner, while browsing through landing pages of cookie-less analytics solutions 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fly99ywfq3g0ii6gbszmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fly99ywfq3g0ii6gbszmj.png" alt="Image description" width="800" height="390"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;a website for a cookie-less solution displaying a cookie banner&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: The information provided in this article is for general informational purposes only and does not constitute legal advice. While I strive to ensure the accuracy and reliability of the information presented, it is not a substitute for professional legal consultation. Please consult with a qualified legal professional for advice regarding specific legal issues or concerns related to consent mode and privacy regulations. Also, &lt;strong&gt;make sure to comment if you have any doubts&lt;/strong&gt; - I will be more than happy to edit the article.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>google</category>
      <category>privacy</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Bootstrap Tutorials: Navbar</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Wed, 10 Jul 2024 12:43:50 +0000</pubDate>
      <link>https://dev.to/keepcoding/bootstrap-tutorials-navbar-2j8j</link>
      <guid>https://dev.to/keepcoding/bootstrap-tutorials-navbar-2j8j</guid>
      <description>&lt;h2&gt;
  
  
  Navbar
&lt;/h2&gt;

&lt;p&gt;Navbar is a complex component with a lot of options available.&lt;/p&gt;

&lt;p&gt;However, since in any project good navigation is an absolutely key element of the interface, in this lesson we will look at the Bootstrap navbar in depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - add the navbar basic example to the project
&lt;/h2&gt;

&lt;p&gt;Go to the navbar documentation page and copy the code of the basic example. Then paste it into the index.html file, inside of the  section.&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 Navigation--&amp;gt;
&amp;lt;header&amp;gt;

    &amp;lt;!-- Navbar --&amp;gt;
    &amp;lt;nav class="navbar navbar-expand-lg navbar-light bg-body-tertiary"&amp;gt;
      &amp;lt;!-- Container wrapper --&amp;gt;
      &amp;lt;div class="container-fluid"&amp;gt;
        &amp;lt;!-- Toggle button --&amp;gt;
        &amp;lt;button
          data-mdb-collapse-init
          class="navbar-toggler"
          type="button"
          data-mdb-target="#navbarSupportedContent"
          aria-controls="navbarSupportedContent"
          aria-expanded="false"
          aria-label="Toggle navigation"
        &amp;gt;
          &amp;lt;i class="fas fa-bars"&amp;gt;&amp;lt;/i&amp;gt;
        &amp;lt;/button&amp;gt;

        &amp;lt;!-- Collapsible wrapper --&amp;gt;
        &amp;lt;div class="collapse navbar-collapse" id="navbarSupportedContent"&amp;gt;
          &amp;lt;!-- Navbar brand --&amp;gt;
          &amp;lt;a class="navbar-brand mt-2 mt-lg-0" href="#"&amp;gt;
            &amp;lt;img
              src="https://mdbcdn.b-cdn.net/img/logo/mdb-transaprent-noshadows.webp"
              height="15"
              alt="MDB Logo"
              loading="lazy"
            /&amp;gt;
          &amp;lt;/a&amp;gt;
          &amp;lt;!-- Left links --&amp;gt;
          &amp;lt;ul class="navbar-nav me-auto mb-2 mb-lg-0"&amp;gt;
            &amp;lt;li class="nav-item"&amp;gt;
              &amp;lt;a class="nav-link" href="#"&amp;gt;Dashboard&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class="nav-item"&amp;gt;
              &amp;lt;a class="nav-link" href="#"&amp;gt;Team&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class="nav-item"&amp;gt;
              &amp;lt;a class="nav-link" href="#"&amp;gt;Projects&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
          &amp;lt;/ul&amp;gt;
          &amp;lt;!-- Left links --&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;!-- Collapsible wrapper --&amp;gt;

        &amp;lt;!-- Right elements --&amp;gt;
        &amp;lt;div class="d-flex align-items-center"&amp;gt;
          &amp;lt;!-- Icon --&amp;gt;
          &amp;lt;a class="text-reset me-3" href="#"&amp;gt;
            &amp;lt;i class="fas fa-shopping-cart"&amp;gt;&amp;lt;/i&amp;gt;
          &amp;lt;/a&amp;gt;

          &amp;lt;!-- Notifications --&amp;gt;
          &amp;lt;div class="dropdown"&amp;gt;
            &amp;lt;a
              data-mdb-dropdown-init
              class="text-reset me-3 dropdown-toggle hidden-arrow"
              href="#"
              id="navbarDropdownMenuLink"
              role="button"
              aria-expanded="false"
            &amp;gt;
              &amp;lt;i class="fas fa-bell"&amp;gt;&amp;lt;/i&amp;gt;
              &amp;lt;span class="badge rounded-pill badge-notification bg-danger"&amp;gt;1&amp;lt;/span&amp;gt;
            &amp;lt;/a&amp;gt;
            &amp;lt;ul
              class="dropdown-menu dropdown-menu-end"
              aria-labelledby="navbarDropdownMenuLink"
            &amp;gt;
              &amp;lt;li&amp;gt;
                &amp;lt;a class="dropdown-item" href="#"&amp;gt;Some news&amp;lt;/a&amp;gt;
              &amp;lt;/li&amp;gt;
              &amp;lt;li&amp;gt;
                &amp;lt;a class="dropdown-item" href="#"&amp;gt;Another news&amp;lt;/a&amp;gt;
              &amp;lt;/li&amp;gt;
              &amp;lt;li&amp;gt;
                &amp;lt;a class="dropdown-item" href="#"&amp;gt;Something else here&amp;lt;/a&amp;gt;
              &amp;lt;/li&amp;gt;
            &amp;lt;/ul&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;!-- Avatar --&amp;gt;
          &amp;lt;div class="dropdown"&amp;gt;
            &amp;lt;a
              data-mdb-dropdown-init
              class="dropdown-toggle d-flex align-items-center hidden-arrow"
              href="#"
              id="navbarDropdownMenuAvatar"
              role="button"
              aria-expanded="false"
            &amp;gt;
              &amp;lt;img
                src="https://mdbcdn.b-cdn.net/img/new/avatars/2.webp"
                class="rounded-circle"
                height="25"
                alt="Black and White Portrait of a Man"
                loading="lazy"
              /&amp;gt;
            &amp;lt;/a&amp;gt;
            &amp;lt;ul
              class="dropdown-menu dropdown-menu-end"
              aria-labelledby="navbarDropdownMenuAvatar"
            &amp;gt;
              &amp;lt;li&amp;gt;
                &amp;lt;a class="dropdown-item" href="#"&amp;gt;My profile&amp;lt;/a&amp;gt;
              &amp;lt;/li&amp;gt;
              &amp;lt;li&amp;gt;
                &amp;lt;a class="dropdown-item" href="#"&amp;gt;Settings&amp;lt;/a&amp;gt;
              &amp;lt;/li&amp;gt;
              &amp;lt;li&amp;gt;
                &amp;lt;a class="dropdown-item" href="#"&amp;gt;Logout&amp;lt;/a&amp;gt;
              &amp;lt;/li&amp;gt;
            &amp;lt;/ul&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;!-- Right elements --&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;!-- Container wrapper --&amp;gt;
    &amp;lt;/nav&amp;gt;
    &amp;lt;!-- Navbar --&amp;gt;

&amp;lt;/header&amp;gt;
&amp;lt;!--Main Navigation--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and refresh the browser. You should see the navigation bar.&lt;/p&gt;

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

&lt;p&gt;Kind of like a normal navigation bar, right? So why so much code? Let's break it down into smaller chunks and analyze it one by one.&lt;/p&gt;

&lt;p&gt;Let's first look at the main, outermost element of the navbar.&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;!-- Navbar --&amp;gt;
&amp;lt;nav class="navbar navbar-expand-lg navbar-light bg-body-tertiary"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;navbar class&lt;/strong&gt; provides a base styling and behavior for the component. If you remove it, it will be completely broken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;navbar-expand-lg&lt;/strong&gt; class defines at which breakpoint (that is, above which screen size) the navbar will &lt;strong&gt;expand&lt;/strong&gt; and changes from the mobile to the desktop view. As you remember from the &lt;a href="https://mdbootstrap.com/learn/mdb-foundations/bootstrap/grid-system/" rel="noopener noreferrer"&gt;previous lesson about grid&lt;/a&gt;, breakpoint &lt;em&gt;-lg&lt;/em&gt; means equal or above 992px. If you want to change the breakpoint you can choose from the &lt;a href="https://mdbootstrap.com/docs/standard/layout/breakpoints/#section-available-breakpoints" rel="noopener noreferrer"&gt;available options&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;navbar-light class&lt;/strong&gt; defines that the navbar links should be adjusted to the light background. You can change it to the navbar-dark class and the links will turn white, so you will need to change the background color of the navbar to something dark, to provide proper contrast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;bg-body-tertiary&lt;/strong&gt; defines the background color of the navbar as a very light grey in a light mode, and light dark in a dark mode. If you don't want / don't need switching between light/dark modes you can define whatever single color you want and stick with it - for example &lt;em&gt;bg-dark&lt;/em&gt; or other &lt;a href="https://mdbootstrap.com/docs/standard/content-styles/colors/#subsection-background" rel="noopener noreferrer"&gt;available colors&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2 - modify the navbar
&lt;/h2&gt;

&lt;p&gt;Making use of the knowledge above, let's tinker a little on the navbar. Change the outermost element as follows:&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;!-- Navbar --&amp;gt;
&amp;lt;nav class="navbar navbar-expand-lg navbar-dark bg-dark"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Navbar seems kind of broken right now, as for example, the elements on the right are barely visible. But don't worry, we'll fix it soon.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; As I mentioned before, we will learn in details about theming and dark mode in the future lessons and next projects. In this project we will not switch between light/dark mode, so we can use hardcoded color like &lt;strong&gt;bg-dark&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 - change the container
&lt;/h2&gt;

&lt;p&gt;The next element we will look at is already well known to us. It's a container that allows us to set basic margins for our layout. As you can see now, it is a &lt;em&gt;container-fluid&lt;/em&gt;, i.e. a container without margins, stretched to full width.&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;!-- Container wrapper --&amp;gt;
&amp;lt;div class="container-fluid"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change this container to a &lt;em&gt;regular container&lt;/em&gt;, so we can enjoy some margins.&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;!-- Container wrapper --&amp;gt;
&amp;lt;div class="container"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4 - have a look at the toggle button
&lt;/h2&gt;

&lt;p&gt;Below the opening tag of the container element we have a toggle button. It contains a lot of attributes, but we're really only interested in this one: &lt;strong&gt;data-mdb-target="#navbarSupportedContent"&lt;/strong&gt;.&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;!-- Toggle button --&amp;gt;
&amp;lt;button data-mdb-collapse-init class="navbar-toggler" type="button" data-mdb-target="#navbarSupportedContent"
  aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"&amp;gt;
  &amp;lt;i class="fas fa-bars"&amp;gt;&amp;lt;/i&amp;gt;
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, it points to an element with a specific id, which is &lt;strong&gt;#navbarSupportedContent&lt;/strong&gt;. If you look at your &lt;strong&gt;index.html&lt;/strong&gt; file, at the navbar, you'll see that the &lt;strong&gt;collapse&lt;/strong&gt; class element contains just such an id. This means that our toggle button will trigger the &lt;strong&gt;collapse&lt;/strong&gt; element &lt;strong&gt;with this specific id&lt;/strong&gt; (&lt;em&gt;#navbarSupportedContent&lt;/em&gt;) when the navbar collapses to the mobile view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgq8ht06cz4q0tkcixs4s.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgq8ht06cz4q0tkcixs4s.gif" alt="Image description" width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that the toggle button (also called hamburger) is not visible in the desktop view. It only appears when the navbar collapses to mobile view (specifically, when the screen is smaller than the breakpoint we set in the &lt;strong&gt;navbar-expand-lg class&lt;/strong&gt;, so &lt;strong&gt;992px&lt;/strong&gt; in this case)&lt;/p&gt;

&lt;p&gt;Below the toggle button we have the collapse element with an id navbarSupportedContent we just mentioned.&lt;/p&gt;

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

&lt;p&gt;Inside of this collapse we need to place all the elements we want to be hidden on the mobile view.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 5 - change &lt;em&gt;navbar-brand&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;The first element inside the collapser is the &lt;strong&gt;navbar-brand&lt;/strong&gt; element. In this case, it is a graphic with the MDB logo.&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;a href="#"&amp;gt;
  &amp;lt;img src="https://mdbcdn.b-cdn.net/img/logo/mdb-transaprent-noshadows.webp" alt="MDB Logo"&amp;gt;
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;We could put some other graphic in there, but we'll go a different route and use an icon instead.&lt;/p&gt;

&lt;p&gt;Go to the &lt;a href="https://mdbootstrap.com/docs/standard/content-styles/icons/#section-icon-search" rel="noopener noreferrer"&gt;icon documentation page&lt;/a&gt; and choose the icon you like. I chose the diamond icon .&lt;/p&gt;

&lt;p&gt;Then replace the &lt;em&gt;img&lt;/em&gt; element with this icon and additionally add text-secondary class to it, to change the color to nice grey tint.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyw71er7smqo2mt2wd3hu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyw71er7smqo2mt2wd3hu.png" alt="Image description" width="535" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This one is as a image, because whoever invented markdown hates humanity. Or at least this part that uses written word&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After saving the file and refreshing the browser, you should see the icon of your choice in the navbar instead of the MDB logo.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpk3jci62dxasr2vzsrwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpk3jci62dxasr2vzsrwj.png" alt="Image description" width="800" height="105"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 6 - change the &lt;em&gt;links&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Below the **navbar-brand **element you will find links:&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;ul&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href="#"&amp;gt;Dashboard&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href="#"&amp;gt;Team&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href="#"&amp;gt;Projects&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

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

&lt;/div&gt;
&lt;p&gt;It's a very simple element and there's not much to go into here. However, we will make a few changes.&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;ul&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href="#"&amp;gt;About&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href="#"&amp;gt;Projects&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;a href="#"&amp;gt;Contact&amp;lt;/a&amp;gt;
  &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

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

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;What we did:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We changed the text in the links (to About, Projects and Contact) to correspond to future sections of our landing page that we will create in future lessons.&lt;/li&gt;
&lt;li&gt;We added a &lt;em&gt;text-secondary&lt;/em&gt; class to make the links the same color as the &lt;em&gt;navbar-brand&lt;/em&gt; element.&lt;/li&gt;
&lt;li&gt;We added the &lt;em&gt;fw-bold&lt;/em&gt; class to the links to make the text bolder. ("fw" is short for "font weight"). If you want to check other available options for changing the font have a look at &lt;a href="https://mdbootstrap.com/docs/standard/utilities/text/#section-font-weight-and-italics" rel="noopener noreferrer"&gt;text documentation page&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how it should look like now:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zfovrsl15ig9i5h3k3y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zfovrsl15ig9i5h3k3y.png" alt="Image description" width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7 - change the icons&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below the collaps you will find icons embedded in a div labeled &lt;em&gt;"Right elements"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;That they are placed outside the collapse - this means they will still be visible on the mobile view and this is desirable behavior.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; As you can see, the d-flex and align-items-center classes are present here. They concern flexbox, another powerful Bootstrap tool. We'll explore them in detail in later lessons, but for now let's just leave them as they are.&lt;/em&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;a href="#"&amp;gt;

  &amp;lt;/a&amp;gt;



    &amp;lt;a href="#" id="navbarDropdownMenuLink"&amp;gt;

      &amp;lt;span&amp;gt;1&amp;lt;/span&amp;gt;
    &amp;lt;/a&amp;gt;
    &amp;lt;ul&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a href="#"&amp;gt;Some news&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a href="#"&amp;gt;Another news&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a href="#"&amp;gt;Something else here&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;



    &amp;lt;a href="#" id="navbarDropdownMenuAvatar"&amp;gt;
      &amp;lt;img src="https://mdbcdn.b-cdn.net/img/new/avatars/2.webp" alt="Black and White Portrait of a Man"&amp;gt;
    &amp;lt;/a&amp;gt;
    &amp;lt;ul&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a href="#"&amp;gt;My profile&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a href="#"&amp;gt;Settings&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a href="#"&amp;gt;Logout&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;




&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;


In addition to the usual static shopping cart icon, you will also find two drop-down menus: **"Notifications"** and **"Avatar"**.

Since this lesson is getting really long, we'll cover dropdowns in future lessons. So let's replace them with 2 other static icons. We will simply copy the icon of the shopping cart and paste it 2 more times.

**HTML**


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




  &amp;lt;a href="#"&amp;gt;

  &amp;lt;/a&amp;gt;
  &amp;lt;a href="#"&amp;gt;

  &amp;lt;/a&amp;gt;
  &amp;lt;a href="#"&amp;gt;

  &amp;lt;/a&amp;gt;



&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;

Now we want to replace these icons with social media icons and link external pages to them. In addition, as with the previous links, we will add a _text-secondary_ class to make them color-coherent with the rest.

And again - you can use our [huge collection of icons](https://mdbootstrap.com/docs/standard/content-styles/icons/#section-icon-search) and choose the icons you want and link them wherever you want.

**HTML**


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




  &amp;lt;a href="https://www.youtube.com/c/Mdbootstrap/videos" rel="nofollow"&amp;gt;

  &amp;lt;/a&amp;gt;

  &amp;lt;a href="https://twitter.com/ascensus_mdb" rel="nofollow"&amp;gt;

  &amp;lt;/a&amp;gt;

  &amp;lt;a href="https://github.com/mdbootstrap/mdb-ui-kit" rel="nofollow"&amp;gt;

  &amp;lt;/a&amp;gt;




&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;


And this should be the final result of our modifications in the navbar:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wugrski0bcg3pboojnr4.png)

Huh, that was a long one! You can safely feel satisfied, because we have processed a lot of important and quite heavy material. Good job!

**[Demo &amp;amp;amp; Source for this lesson](https://mdbootstrap.com/snippets/standard/ascensus/4609180)**
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>bootstrap</category>
      <category>javascript</category>
      <category>html</category>
      <category>beginners</category>
    </item>
    <item>
      <title>TailwindCSS Text. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Tue, 09 Jul 2024 15:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/tailwindcss-text-free-uiux-design-course-4p6f</link>
      <guid>https://dev.to/keepcoding/tailwindcss-text-free-uiux-design-course-4p6f</guid>
      <description>&lt;h2&gt;
  
  
  Text
&lt;/h2&gt;

&lt;p&gt;At the end of the previous lesson, we finally managed to place the Call to action elements perfectly in the center of our Hero Image. But the result is far from satisfactory.&lt;/p&gt;

&lt;p&gt;First of all, you can hardly see anything here!&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhj13fsp1ld5kr1pfa3d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhj13fsp1ld5kr1pfa3d6.png" alt="Image description" width="653" height="354"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1 - change the color of the text
&lt;/h2&gt;

&lt;p&gt;Changing the text color in Tailwind is simple and we've talked about it in the previous lesson. To change it, for example, to white, just add the .text-white class to the element.&lt;/p&gt;

&lt;p&gt;Then all elements that are its children will take this property. So add .text-white class to the parent element of our Call to action:&lt;/p&gt;

&lt;p&gt;By the way - we can remove .p-10 class, which was added at the beginning of the previous lesson when the Navbar was covering Call to action. We don't need it anymore.&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;!-- Call to action --&amp;gt;
&amp;lt;div class="text-white"&amp;gt;
  &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
  &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmewktj4ejdfge224y6zt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmewktj4ejdfge224y6zt.png" alt="Image description" width="553" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Slightly better, but still the contrast against the background is too weak. We'll get to that soon. Now let's try to improve the text itself a bit more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 - change the size of the text
&lt;/h2&gt;

&lt;p&gt;By default, the typography in Tailwind has no styling, which makes headings like h1, h2. h3 etc. and paragraphs look the same.&lt;/p&gt;

&lt;p&gt;So to make the h1 element look like the most important heading on the page, we need to use the Tailwind classes.&lt;/p&gt;

&lt;p&gt;In Tailwind you can control the font size of any element, including headings, with the text-{size} utility. For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;text-xs:&lt;/strong&gt; Extra small text size&lt;br&gt;
** text-sm:** Small text size&lt;br&gt;
&lt;strong&gt;text-base:&lt;/strong&gt; Base text size (approximately equivalent to the browser default)&lt;br&gt;
&lt;strong&gt;text-lg:&lt;/strong&gt; Large text size&lt;br&gt;
&lt;strong&gt;text-xl:&lt;/strong&gt; Extra-large text size&lt;br&gt;
&lt;strong&gt;text-2xl&lt;/strong&gt; through **text-9xl: **Incrementally larger text sizes&lt;/p&gt;

&lt;p&gt;So let's add &lt;strong&gt;.text-5xl&lt;/strong&gt; class to h1 element in our Call to action, and &lt;strong&gt;.text-2xl&lt;/strong&gt; to the &lt;strong&gt;h2:&lt;/strong&gt;&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;!-- Call to action --&amp;gt;
&amp;lt;div class="text-white"&amp;gt;
  &amp;lt;h1 class="text-5xl"&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
  &amp;lt;h2 class="text-2xl"&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's taking shape, but there's still a lot of work to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 - change the weight of the text
&lt;/h2&gt;

&lt;p&gt;You can control the font weight of any element, including headings, with the font-{weight} utility. Have a look at a list of classes you could use:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;font-thin:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;100&lt;/strong&gt;&lt;br&gt;
** font-extralight:** Sets the font weight to &lt;strong&gt;200&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;font-light:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;300&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;font-normal:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;400&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;font-medium:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;500&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;font-semibold:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;700&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;font-extrabold:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;800&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;font-black:&lt;/strong&gt; Sets the font weight to &lt;strong&gt;900&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So let's add &lt;strong&gt;.font-semibold"&lt;/strong&gt; class to h1 element in our Call to action, and &lt;strong&gt;.font-medium to the h2:&lt;/strong&gt;&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;!-- Call to action --&amp;gt;
&amp;lt;div class="text-white"&amp;gt;
  &amp;lt;h1 class="text-5xl font-semibold"&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
  &amp;lt;h2 class="text-2xl font-medium"&amp;gt;
    And what an exciting adventure it is!
  &amp;lt;/h2&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Focdvc096ipkif3o39qiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Focdvc096ipkif3o39qiv.png" alt="Image description" width="636" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Better. Now let's center it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4 - center the text
&lt;/h2&gt;

&lt;p&gt;It is true that we managed to center the Call to action in relation to the Hero Image, but still elements such as headings or the button are pressed to the left edge of the Call to Action. It would be nice if they were fully centered.&lt;/p&gt;

&lt;p&gt;This is also very easy to do in Tailwind. Just add the text-center class to the Call to action element.&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;!-- Call to action --&amp;gt;
&amp;lt;div class="text-center text-white"&amp;gt;
  &amp;lt;h1 class="text-5xl font-semibold"&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
  &amp;lt;h2 class="text-2xl font-medium"&amp;gt;
    And what an exciting adventure it is!
  &amp;lt;/h2&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9w19cna15lroabpkec5c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9w19cna15lroabpkec5c.png" alt="Image description" width="651" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now &lt;strong&gt;Call to action&lt;/strong&gt; looks much better, but there is still a lot of work ahead of us.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can also try our &lt;strong&gt;&lt;a href="https://www.designtoolshub.com/tailwind-css/typography-generator" rel="noopener noreferrer"&gt;Typography generator&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tw-elements.com/snippets/tailwind/ascensus/5335291" rel="noopener noreferrer"&gt;DEMO AND SOURCE CODE FOR THIS LESSON&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>learning</category>
      <category>webdev</category>
      <category>design</category>
    </item>
    <item>
      <title>Bootstrap Tutorials: Create a Landing Page</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Thu, 04 Jul 2024 07:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/bootstrap-tutorials-create-a-landing-page-534i</link>
      <guid>https://dev.to/keepcoding/bootstrap-tutorials-create-a-landing-page-534i</guid>
      <description>&lt;h2&gt;
  
  
  Create a Landing Page
&lt;/h2&gt;

&lt;p&gt;Hey, this is a very exciting moment! Do you know why?&lt;/p&gt;

&lt;p&gt;You have already learned the theoretical basis of the most important topics of Bootstrap. So now we can roll up our sleeves and have some fun while learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will create a real-life project.&lt;/strong&gt; It will be a beautiful Landing Page with impressive photography stretched to full screen.&lt;/p&gt;

&lt;p&gt;Click &lt;a href="https://ascensus-bootstrap-tutorial.mdbgo.io/"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; to see its final version:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's start!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - prepare index.html file
&lt;/h2&gt;

&lt;p&gt;In the folder of our project, which we prepared in the previous lessons, there are leftovers of the code from the lesson about the grid.&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="container" style="height: 500px; background-color: red"&amp;gt;

  &amp;lt;div class="row" style="background-color: blue;"&amp;gt;
    I am a first row
  &amp;lt;/div&amp;gt;

  &amp;lt;div class="row" style="background-color: lightblue;"&amp;gt;
    I am a second row
  &amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove this&lt;/strong&gt; so we can start with a clean document.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 - prepare the basic structure
&lt;/h2&gt;

&lt;p&gt;Our project needs a basic structure to keep the code organized.&lt;/p&gt;

&lt;p&gt;It may not seem that important at first, but you will appreciate this approach when the amount of code starts to grow exponentially.&lt;/p&gt;

&lt;p&gt;Add the following code to your &lt;em&gt;index.html&lt;/em&gt; file:&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 Navigation--&amp;gt;
&amp;lt;header&amp;gt;

&amp;lt;/header&amp;gt;
&amp;lt;!--Main Navigation--&amp;gt;

&amp;lt;!--Main layout--&amp;gt;
&amp;lt;main&amp;gt;
  &amp;lt;div class="container"&amp;gt;

  &amp;lt;/div&amp;gt;
&amp;lt;/main&amp;gt;
&amp;lt;!--Main layout--&amp;gt;

&amp;lt;!--Footer--&amp;gt;
&amp;lt;footer&amp;gt;

&amp;lt;/footer&amp;gt;
&amp;lt;!--Footer--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After saving the file and refreshing your browser, you will see a blank page. This is fine, because the structure we added doesn't have any elements to render yet.&lt;/p&gt;

&lt;p&gt;But that will change soon. Next time - Navigation!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://mdbootstrap.com/snippets/standard/ascensus/4609175"&gt;Demo &amp;amp; source code for this lesson&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>website</category>
      <category>tutorial</category>
      <category>bootstrap</category>
      <category>webdev</category>
    </item>
    <item>
      <title>TailwindCSS Flexbox. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Wed, 03 Jul 2024 09:59:34 +0000</pubDate>
      <link>https://dev.to/keepcoding/tailwindcss-flexbox-free-uiux-design-course-5fnc</link>
      <guid>https://dev.to/keepcoding/tailwindcss-flexbox-free-uiux-design-course-5fnc</guid>
      <description>&lt;h2&gt;
  
  
  Flexbox
&lt;/h2&gt;

&lt;p&gt;It's time to take a look at another famous Tailwind CSS tool - flexbox.&lt;/p&gt;

&lt;p&gt;In fact, flexbox itself is not a creation of Tailwind, but simply CSS, but thanks to Tailwind, we can comfortably use flexbox using the class utilities.&lt;/p&gt;

&lt;p&gt;But enough talk, let's explain it better with examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - add headings
&lt;/h2&gt;

&lt;p&gt;Our Hero Image is impressive, but since it contains no content, it is of little use.&lt;/p&gt;

&lt;p&gt;We need to add some kind of &lt;strong&gt;Call to action&lt;/strong&gt;. One big heading and one subheading should be enough for now.&lt;/p&gt;

&lt;p&gt;Let's do it. Inside the &lt;em&gt;div&lt;/em&gt; with our &lt;strong&gt;Hero Image&lt;/strong&gt;, let's add another div with headings inside.&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;!-- Background image --&amp;gt;
&amp;lt;div
  class="h-screen bg-cover bg-no-repeat"
  style="margin-top: -56px; background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;
  &amp;lt;!-- Call to action --&amp;gt;
  &amp;lt;div class="pt-20"&amp;gt;
    &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;!-- Background image --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They appear in the upper left corner of the screen and are covered by the Navbar, so we need to add padding with &lt;em&gt;.pt-20 class&lt;/em&gt; to see anything at all. This is definitely not a satisfactory solution.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwacd7h7y45c8oo7zdnz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwacd7h7y45c8oo7zdnz4.png" alt="Image description" width="415" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have to figure out a way to perfectly center them horizontally and vertically. Regardless of the size of the screen, we want our &lt;strong&gt;Call to action&lt;/strong&gt; to appear in the &lt;strong&gt;center&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Difficult task. But fortunately, we have &lt;strong&gt;flexbox&lt;/strong&gt; at our disposal, thanks to which we will deal with it in the blink of an eye.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2 - add flexbox
&lt;/h2&gt;

&lt;p&gt;First, we need to place our Call To Action in an outer &lt;em&gt;div&lt;/em&gt; that will handle flexbox.&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;!-- Background image --&amp;gt;
&amp;lt;div
  class="h-screen bg-cover bg-no-repeat"
  style="margin-top: -56px; background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;
  &amp;lt;!-- Wrapper for flexbox --&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;!-- Call to action --&amp;gt;
    &amp;lt;div class="pt-10"&amp;gt;
      &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
      &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;!-- Background image --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to &lt;strong&gt;enable flexbox&lt;/strong&gt;. We do this by adding the &lt;em&gt;.flex class&lt;/em&gt; to the outer wrapper &lt;em&gt;div&lt;/em&gt;.&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;!-- Wrapper for flexbox --&amp;gt;
&amp;lt;div class="flex"&amp;gt;
  &amp;lt;!-- Call to action --&amp;gt;
  &amp;lt;div class="pt-10"&amp;gt;
    &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So far, so good, but nothing changes after we save the file.&lt;/p&gt;

&lt;p&gt;And that's because enabling flexbox is only the first step. Now we need to choose one of the many available options to define how exactly we want to align given elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Horizontal alignment&lt;/strong&gt;&lt;br&gt;
To center elements horizontally, we use the justify-center class. Let's add it next to the &lt;em&gt;.flex&lt;/em&gt; class.&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;!-- Wrapper for flexbox --&amp;gt;
&amp;lt;div class="flex justify-center"&amp;gt;
  &amp;lt;!-- Call to action --&amp;gt;
  &amp;lt;div class="pt-10"&amp;gt;
    &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Vertical alignment&lt;/strong&gt;&lt;br&gt;
To center elements vertically, we use the items-center class. Let's also add it next to the &lt;em&gt;.flex&lt;/em&gt; class.&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;!-- Wrapper for flexbox --&amp;gt;
&amp;lt;div class="flex items-center justify-center"&amp;gt;
  &amp;lt;!-- Call to action --&amp;gt;
  &amp;lt;div class="pt-10"&amp;gt;
    &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After saving the file, it will turn out... that nothing has changed 🤔&lt;/p&gt;

&lt;p&gt;However, if you look closely, you'll see that's not true - vertical centering worked as well.&lt;/p&gt;

&lt;p&gt;The problem, however, is that the height of the &lt;em&gt;div&lt;/em&gt; on which we run flexbox is only as high as the height of the elements it contains. As a result, there is no visual effect of vertical centering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 - set a height
&lt;/h2&gt;

&lt;p&gt;Let's do an experiment - let's add the &lt;em&gt;bg-red-500 class&lt;/em&gt; to the &lt;em&gt;div&lt;/em&gt; with our flexbox, which will give it a red background. Thanks to this, we will be able to see its actual height.&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;!-- Wrapper for flexbox --&amp;gt;
&amp;lt;div class="flex items-center justify-center bg-red-500"&amp;gt;
  &amp;lt;!-- Call to action --&amp;gt;
  &amp;lt;div class="pt-10"&amp;gt;
    &amp;lt;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at the red rectangle - the &lt;em&gt;flexbox div&lt;/em&gt; ends and begins exactly where its contents end and begin - in this case, &lt;strong&gt;Call to action&lt;/strong&gt; elements.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63l3y1flgb2pou21oc2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63l3y1flgb2pou21oc2o.png" alt="Image description" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To extend the flexbox div to the full height of our Hero Image, we need to set its height equal to 100% of the available space.&lt;/p&gt;

&lt;p&gt;This is very easy to do with Tailwind. Just add the &lt;em&gt;.h-full class&lt;/em&gt; to the flexbox &lt;em&gt;div&lt;/em&gt; ("h" for height, so h-full = height: 100%).&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;h1&amp;gt;I am learning Tailwind&amp;lt;/h1&amp;gt;
&amp;lt;h2&amp;gt;And what an exciting adventure it is!&amp;lt;/h2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After saving the file and refreshing the browser, you will see that this time Call to action is centered both horizontally and vertically.&lt;/p&gt;

&lt;p&gt;You can &lt;strong&gt;remove&lt;/strong&gt; the &lt;em&gt;.bg-red-500&lt;/em&gt; class. It only served us to demonstrate the height of the flexbox div, so we don't need it anymore.&lt;/p&gt;

&lt;p&gt;We still have a lot to improve on our *&lt;em&gt;Call to action *&lt;/em&gt;(like poor visibility), but we'll cover that in the future lessons.&lt;/p&gt;

&lt;p&gt;Regarding flexbox - in this lesson we have learned only the basic functionalities. We will cover advanced topics many times in the future, because flexbox is useful in virtually every project.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you want to practice on your own and have a look at more examples you can play with our &lt;strong&gt;&lt;a href="https://www.designtoolshub.com/tailwind-css/flexbox-generator"&gt;flexbox generator&lt;/a&gt;&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tw-elements.com/snippets/tailwind/ascensus/5324955"&gt;DEMO AND SOURCE CODE FOR THIS LESSON&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>ui</category>
      <category>uidesign</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Bootstrap Tutorials: Grid system</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Tue, 02 Jul 2024 15:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/bootstrap-tutorials-grid-system-4ka7</link>
      <guid>https://dev.to/keepcoding/bootstrap-tutorials-grid-system-4ka7</guid>
      <description>&lt;h2&gt;
  
  
  Grid system
&lt;/h2&gt;

&lt;p&gt;Bootstrap grid is a powerful system for building mobile-first websites. It uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive.&lt;/p&gt;

&lt;p&gt;Some people even think that grid is the most important reason to use Bootstrap, so in this lesson, we will get to know this incredibly useful tool in depth.&lt;/p&gt;

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

&lt;p&gt;Bootstrap grid needs a container to work properly. We learned about containers in the previous lesson, so we won't dwell on them here.&lt;/p&gt;

&lt;p&gt;In our current project, we have already added a container and it looks like this:&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="container" style="height: 500px; background-color: red"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;And this is what the container should look like when rendered in our browser:&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Row
&lt;/h2&gt;

&lt;p&gt;Next, we need a row.&lt;br&gt;
Rows are wrappers for columns. If you want to split your layout horizontally, use .row. Let's add 2 rows to our container:&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="container" style="height: 500px; background-color: red"&amp;gt;

  &amp;lt;div class="row" style="background-color: blue;"&amp;gt;
    I am a first row
  &amp;lt;/div&amp;gt;

  &amp;lt;div class="row" style="background-color: lightblue;"&amp;gt;
    I am a second row
  &amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; Again, for demonstration purposes, we're adding inline CSS (background colors) to help us visually see the changes we're going to make to our design.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After saving the file and refreshing your browser, you should see 2 new rows.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwe8j0j713jfn1aj43qq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwe8j0j713jfn1aj43qq4.png" alt="Image description" width="800" height="72"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Columns
&lt;/h2&gt;

&lt;p&gt;Then it's time for the columns. Bootstrap grid allows you to add up to 12 columns in one line. If you add more than 12, the excess column will jump to the next line.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaqvkaluvubl5uz22crb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaqvkaluvubl5uz22crb.png" alt="Image description" width="800" height="79"&gt;&lt;/a&gt;&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="container"&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      1
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      2
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      3
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      4
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      5
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      6
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      7
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      8
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      9
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      10
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      11
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;
      12
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Remember:&lt;/strong&gt; for the grid to work properly, you should always place columns in rows, and rows in containers.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Columns are incredibly flexible. You can define how wide each column should be and how each of them should behave on different screen widths. Thanks to this, you can easily adjust your layout for both mobile devices and desktops.&lt;/p&gt;

&lt;p&gt;For example, if you want to insert 2 columns of equal width, you can use the following code:&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="container"&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-6"&amp;gt;First column&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-6"&amp;gt;Second column&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;As you can see, we've added the digits 6 to the col class. This (col-6 class) means that we want each column to be 6 units wide.&lt;/p&gt;

&lt;p&gt;You can freely set the width of the columns, just remember that the sum of their width units &lt;strong&gt;does not exceed 12&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;col-6 + col-6 together give 12 units, which means 2 identical columns.&lt;/p&gt;

&lt;p&gt;If you would like the right column to be slightly larger than the left column, you can set it as follows:&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="container"&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-4"&amp;gt;First column&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-8"&amp;gt;Second column&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fww5zpv4k9zbik8fvgpo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fww5zpv4k9zbik8fvgpo2.png" alt="Image description" width="800" height="98"&gt;&lt;/a&gt;&lt;br&gt;
4 (col-4) + 8 (col-8) = 12&lt;/p&gt;

&lt;p&gt;This way you've created a very typical layout with the main column on the right and the sidebar space on the left - that's exactly the scheme this tutorial uses!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;However, there is one problem with the above example&lt;/strong&gt; - no matter the screen size, our columns remain in the same aspect ratio.&lt;/p&gt;

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

&lt;p&gt;The 4/8 ratio is very useful on large screens where there is plenty of space. However, on mobile devices, dividing a small screen additionally into 2 parts of 4 and 8 units is not acceptable. It would not be comfortable to use such a layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here again, breakpoints come to the rescue.&lt;/strong&gt; Do you remember the definition below from our previous lesson?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Breakpoints&lt;/strong&gt; are the triggers in Bootstrap for how your layout responsive changes across device or viewport sizes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As in containers, we can also use breakpoints in columns and define from what width we want the column to extend to full width.&lt;/p&gt;

&lt;p&gt;Taking the example from earlier, let's say we want both of our columns to be &lt;strong&gt;full-width&lt;/strong&gt; on small and medium screens, and to change to a &lt;strong&gt;4/8 ratio&lt;/strong&gt; on large screens.&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="container"&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-md-4"&amp;gt;First column&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-8"&amp;gt;Second column&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All we have to do is add a breakpoint -md (meaning "medium screen size") to the col class, so that the Bootstrap grid knows that we want 4/8 columns ratio only on screens bigger than medium size, and on other screens (medium and small size) the columns should be stretched to full width.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j9zrpbhm78rm0m55lmz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j9zrpbhm78rm0m55lmz.gif" alt="Image description" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To sum up&lt;/strong&gt; - by using class col-md-4, we tell grid the following command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On screens &lt;strong&gt;smaller than 768px&lt;/strong&gt;, I want this column to stretch to full width&lt;/li&gt;
&lt;li&gt;On screens &lt;strong&gt;larger than 768px&lt;/strong&gt;, I want this column to be 4 units wide&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take a look at the table below and see what breakpoints you can use when creating a layout:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frx3l26qyiu88uzh3nzh8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frx3l26qyiu88uzh3nzh8.png" alt="Image description" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay, enough of this theory. Now let's work on some real life examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Three equal columns&lt;/strong&gt;&lt;br&gt;
Get three equal-width columns starting at desktops and scaling to large desktops. On mobile devices, tablets and below, the columns will automatically stack.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6drnl663n6ly799t4ysn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6drnl663n6ly799t4ysn.png" alt="Image description" width="800" height="105"&gt;&lt;/a&gt;&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="container"&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-md-4"&amp;gt;.col-md-4&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-4"&amp;gt;.col-md-4&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-4"&amp;gt;.col-md-4&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Three unequal columns&lt;/strong&gt;&lt;br&gt;
Get three columns starting at desktops and scaling to large desktops of various widths. Remember, grid columns should add up to twelve for a single horizontal block. More than that, and columns start stacking no matter the viewport.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbfb90twet4xvu81qhd2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbfb90twet4xvu81qhd2.png" alt="Image description" width="800" height="104"&gt;&lt;/a&gt;&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="container"&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-md-3"&amp;gt;.col-md-3&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-6"&amp;gt;.col-md-6&amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-3"&amp;gt;.col-md-3&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Two columns with two nested columns&lt;/strong&gt;&lt;br&gt;
Nesting is easy—just put a row of columns within an existing column. This gives you two columns starting at desktops and scaling to large desktops, with another two (equal widths) within the larger column.&lt;/p&gt;

&lt;p&gt;At mobile device sizes, tablets and down, these columns and their nested columns will stack.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprwc30j43mqbmrnaz9ox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprwc30j43mqbmrnaz9ox.png" alt="Image description" width="800" height="158"&gt;&lt;/a&gt;&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="container"&amp;gt;

  &amp;lt;!-- Outer row --&amp;gt;
  &amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-md-8"&amp;gt;
      .col-md-8

      &amp;lt;!-- Inner row --&amp;gt;
      &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-md-6"&amp;gt;.col-md-6&amp;lt;/div&amp;gt;
        &amp;lt;div class="col-md-6"&amp;gt;.col-md-6&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-4"&amp;gt;.col-md-4&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think you now have a rough idea of how it works.&lt;/p&gt;

&lt;p&gt;Bootstrap grid is a very advanced tool and at first its use can be overwhelming. If you feel that not everything is clear to you - &lt;strong&gt;that's completely normal and fine&lt;/strong&gt;. It just takes practice. You will gain confidence and fluency over time.&lt;/p&gt;

&lt;p&gt;It's been a long lesson, but don't hesitate to repeat it to yourself to consolidate your knowledge. If you want to practice on your own and have a look at more examples read the &lt;strong&gt;&lt;a href="https://mdbootstrap.com/docs/standard/layout/grid/"&gt;grid system documentation page&lt;/a&gt;&lt;/strong&gt; or play with our &lt;strong&gt;&lt;a href="https://mdbootstrap.com/docs/standard/tools/builders/grid/"&gt;grid generator&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://mdbootstrap.com/snippets/standard/ascensus/4609158"&gt;Demo &amp;amp; source code for this lesson&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>bootstrap</category>
      <category>learning</category>
      <category>grid</category>
      <category>design</category>
    </item>
    <item>
      <title>TailwindCSS Arbitrary values. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Mon, 01 Jul 2024 16:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/tailwindcss-arbitrary-vvalues-free-uiux-design-course-20g3</link>
      <guid>https://dev.to/keepcoding/tailwindcss-arbitrary-vvalues-free-uiux-design-course-20g3</guid>
      <description>&lt;h2&gt;
  
  
  Arbitrary values
&lt;/h2&gt;

&lt;p&gt;Arbitrary value support in Tailwind CSS allows you to use any custom value with any utility where it makes sense. It's a powerful feature introduced in Tailwind CSS v2.2. This means you're no longer limited by the values defined in your configuration file and can use any value you need right in your HTML.&lt;/p&gt;

&lt;p&gt;For example, if you want to set a width that isn't available in Tailwind CSS classes, you can now do so like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;div class="w-[123px]"&amp;gt;[...]&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the above example, [123px] is an arbitrary value that sets the width of the element to 123px.&lt;/p&gt;
&lt;h2&gt;
  
  
  Arbitrary values with modifiers
&lt;/h2&gt;

&lt;p&gt;You can also use arbitrary values with responsive design, hover state, etc:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;div class="hover:w-[123px] md:w-[456px]"&amp;gt;[...]&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this example, the width of the element will be 456px on medium screens (md:w-[456px]), and the width will change to 123px on hover (hover:w-[123px]).&lt;/p&gt;

&lt;p&gt;This feature also supports other units, not just pixels. You can use rem units, percentages, etc. Additionally, you can use this feature with most of the utility classes in Tailwind CSS, such as padding, margin, translate, scale, rotate, skew, grid, etc.&lt;/p&gt;

&lt;p&gt;Arbitrary values give you a lot more flexibility and power when using Tailwind CSS. They allow you to have the benefits of utility-first CSS while still being able to use any value you need, right in your markup.&lt;/p&gt;
&lt;h2&gt;
  
  
  Fixing the Hero Image using arbitrary values
&lt;/h2&gt;

&lt;p&gt;In the previous lesson, we finished our fullscreen Hero Image. On large screens, it fills the available space perfectly, down to the pixel.&lt;/p&gt;

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

&lt;p&gt;However, there is a problem in the mobile view - there is a small, empty space at the bottom.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6chxkc3s2hrw1py66o2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6chxkc3s2hrw1py66o2.png" alt="Image description" width="372" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's because Navbar is a flexible component and adapts to its content. In the mobile view, the Navbar collapses and hides most of its elements, which reduces its height.&lt;/p&gt;

&lt;p&gt;And as you remember, we set our Hero Image margin-top: -56px; , because that's the height of the Navbar on large screens.&lt;/p&gt;

&lt;p&gt;So we need to make sure that on other screen sizes the height of the Navbar stays the same, which is 56px.&lt;/p&gt;

&lt;p&gt;This is the perfect opportunity to use arbitrary values.&lt;/p&gt;

&lt;p&gt;Add min-h-[56px] to Navbar.&lt;/p&gt;

&lt;p&gt;The min-h- class defines the minimum height for a given element, and [56px] is the height given in the form of arbitrary values that we want to maintain on all screens.&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;!-- Navbar --&amp;gt;
&amp;lt;nav
  class="flex-no-wrap relative flex min-h-[56px] w-full items-center justify-between bg-white py-2 shadow-md shadow-black/5 dark:bg-neutral-600 dark:shadow-black/10 lg:flex-wrap lg:justify-start lg:py-4"
  data-twe-navbar-ref&amp;gt;
  [...]
&amp;lt;/nav&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it's pixel-perfect on every screen size 🤩&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4ar325w7u2eu6872x1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4ar325w7u2eu6872x1f.png" alt="Image description" width="372" height="664"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tw-elements.com/snippets/tailwind/ascensus/5324520"&gt;DEMO AND SOURCE CODE FOR THIS LESSON&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>learning</category>
      <category>guide</category>
    </item>
    <item>
      <title>Bootstrap Tutorials: Containers</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Thu, 27 Jun 2024 08:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/bootstrap-tutorials-container-9l1</link>
      <guid>https://dev.to/keepcoding/bootstrap-tutorials-container-9l1</guid>
      <description>&lt;h2&gt;
  
  
  Containers
&lt;/h2&gt;

&lt;p&gt;Containers are the most basic layout element in Bootstrap and are required when using default grid system. Containers are used to contain, pad, and (sometimes) center the content within them. Although containers can be nested, most layouts do not require a nested container.&lt;/p&gt;

&lt;p&gt;This is what the container looks like in code:&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="container"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Nothing special. Just a div with class container.&lt;/p&gt;

&lt;p&gt;But now let's check how containers will behave in our Bootstrap project that we started in the previous lesson.&lt;/p&gt;

&lt;p&gt;Add the following code to your project, directly below the opening &lt;em&gt;body&lt;/em&gt; tag.&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="container" style="height: 500px; background-color: red"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; For demonstration purposes, we added an inline CSS to the container that gives it a height of 500px and a red color.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is only to allow you to visually observe the change in the behavior of the container, because by default it would be invisible (by default the container has no color and its height is adjusted to its content - and if there is no content, it has no height). We'll remove this inline CSS later.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After adding this code to your project, save the file and refresh your browser. You should see a red rectangle with white margins on the sides. This is our container. Isn't it beautiful? :)&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Now slowly reduce the browser window size.&lt;/strong&gt; When you get below 576 pixels you will see that the margins are completely gone and the container is 100% of the available width.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3y9y9mnto2saezr5ytat.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3y9y9mnto2saezr5ytat.gif" alt="Image description" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a very desirable behavior that allows us to create responsive layouts, adapted to both large desktop screens and small ones for mobile devices.&lt;/p&gt;

&lt;p&gt;As you can easily guess, margins are needed on large screens, but there is no room for them on small ones - that's why Bootstrap containers adjust their width to the width of the screen.&lt;/p&gt;

&lt;p&gt;This boundary point of &lt;strong&gt;576 pixels&lt;/strong&gt; (px), below which the margins disappear and the container stretches to full width, is called a &lt;strong&gt;breakpoint&lt;/strong&gt;. This is a very important term and we will refer to it often.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Breakpoints&lt;/strong&gt; are the triggers in Bootstrap for how your layout responsive changes across device or viewport sizes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Thanks to breakpoints, Bootstrap gives us a lot of flexibility and allows us to decide from what screen width our container (as well as other layout elements, which we will learn later) remove the margins and stretch to full width.&lt;/p&gt;

&lt;p&gt;Have a look at the table below:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55rm3a4y8iq09vuhrw8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55rm3a4y8iq09vuhrw8h.png" alt="Image description" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Can you see this parts -sm , -md, -lg etc., added to the container class? They represent breakpoints (sm for small, md for medium, lg for large, etc.) and define below which width the margins are removed and the container begins to stretch the full available width (i.e. 100% of the width given in the table).&lt;/p&gt;

&lt;p&gt;The default container (i.e. the container class, without any additional characters) has a breakpoint of 576px wide. If you want to make the container convert to full width on screens less than, for example, 992px wide, you need to add xl fragment to the container class.&lt;/p&gt;

&lt;p&gt;Then it should looks like this:&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="container-xl"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Now in your project change our container to an container with the xl breakpoint and again gradually reduce the width of the screen. You will see the margins disappear much sooner than before.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkvhwjbf70l32nm8y9b17.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkvhwjbf70l32nm8y9b17.gif" alt="Image description" width="800" height="240"&gt;&lt;/a&gt;&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="container-xl" style="height: 500px; background-color: red"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;And if you want your container to stretch to full width always, regardless of the breakpoint (i.e. on both small and large screens), use the container-fluid class.&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="container-fluid"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;And that's it for now when it comes to containers. Wasn't that hard for such a useful thing, don't you think?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F84d40tyozy5uv250a1t2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F84d40tyozy5uv250a1t2.gif" alt="Image description" width="1609" height="445"&gt;&lt;/a&gt;&lt;br&gt;
Now change the container in your project to the default one. Leave the inline CSS for now, as we'll need it in the next lesson.&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="container" style="height: 500px; background-color: red"&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;And we're done! :)&lt;/p&gt;

</description>
      <category>bootstrap</category>
      <category>tutorial</category>
      <category>html</category>
      <category>ui</category>
    </item>
    <item>
      <title>TailwindCSS Fullscreen background image. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Wed, 26 Jun 2024 10:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/tailwindcss-fullscreen-background-image-free-uiux-design-course-20bf</link>
      <guid>https://dev.to/keepcoding/tailwindcss-fullscreen-background-image-free-uiux-design-course-20bf</guid>
      <description>&lt;h2&gt;
  
  
  Fullscreen background image
&lt;/h2&gt;

&lt;p&gt;You probably know websites with an impressive background photo that cover the entire screen. These intro sections, also called Hero Section or Hero Image, have gained well-deserved recognition.&lt;/p&gt;

&lt;p&gt;They are beautiful, it's true. However, they can cause a lot of frustration, because adapting them to look good on both large screens and mobile devices is a bit of a challenge.&lt;/p&gt;

&lt;p&gt;But don't worry about it. Today is your lucky day because you'll learn how to create full-page Hero Sections that not only look stunning, but also work perfectly on screens of all sizes.&lt;/p&gt;

&lt;p&gt;Let's jump right into the code!&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - add an image
&lt;/h2&gt;

&lt;p&gt;First, we need an image that is high enough resolution to cover even large screens and still look good.&lt;/p&gt;

&lt;p&gt;However, be careful not to overdo it. 4k graphics, additionally unoptimized, can slow down your website so much that the user will leave it angry before he has a chance to admire your Hero Image.&lt;/p&gt;

&lt;p&gt;What's important, we need to add this image not as an &lt;em&gt;img&lt;/em&gt; element but as a background-image of a regular &lt;em&gt;div&lt;/em&gt;. Additionally, we will add this as inline CSS.&lt;/p&gt;

&lt;p&gt;Add the following code to index.html file below the navbar component and above the closing &lt;em&gt;/header&lt;/em&gt; tag.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you want, you can replace the photo with another one. Just make sure you provide the correct link.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Remember that we are adding this image directly to the element as inline CSS.&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;header&amp;gt;
  &amp;lt;!-- Navbar --&amp;gt;
  &amp;lt;nav&amp;gt;[...]&amp;lt;/nav&amp;gt;
  &amp;lt;!-- Navbar --&amp;gt;

  &amp;lt;!-- Add only the code below --&amp;gt;

  &amp;lt;!-- Background image --&amp;gt;
  &amp;lt;div
    style="background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;!-- Background image --&amp;gt;

  &amp;lt;!-- Add only the code above --&amp;gt;
&amp;lt;/header&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After saving the file and refreshing your browser, you will notice that... nothing has changed! But take it easy cowboy, we're just getting started.&lt;/p&gt;

&lt;p&gt;Since we added this image not as an &lt;em&gt;img&lt;/em&gt; element, but as a background-image of a normal &lt;em&gt;/div&lt;/em&gt;, we need to define the height of this div. By default, it has a height of 0, so our image has nowhere to render.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 - set the height of the image placeholder
&lt;/h2&gt;

&lt;p&gt;All right, so let's set the height of our div to, say, 500px.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;!-- Background image --&amp;gt;&lt;br&gt;
&amp;lt;div&lt;br&gt;
  style="height: 500px; background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;lt;!-- Background image --&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After saving the file, you'll see that you can finally see the picture! But something is wrong. Some weird stuff is happening on the right side and it seems that the picture ends and starts again.&lt;/p&gt;

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

&lt;p&gt;And the result is hardly satisfactory at all. We only see the tip of the famous Golden Gate Bridge, and the graphics were supposed to cover the entire screen, not just 500px.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 - fix the image
&lt;/h2&gt;

&lt;p&gt;I think it's time to call upon the magic of Tailwind CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image No Repeat&lt;/strong&gt;&lt;br&gt;
Let's add the .bg-no-repeat class to our image:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;!-- Background image --&amp;gt;&lt;br&gt;
&amp;lt;div&lt;br&gt;
  class="bg-no-repeat"&lt;br&gt;
  style="height: 500px; background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;lt;!-- Background image --&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After saving the file, you will see that the part of the image that was this strange repetition is gone on the right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01pj126ebzpw70kc6r75.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01pj126ebzpw70kc6r75.jpg" alt="Image description" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use .bg-no-repeat when you don't want to repeat the background image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Cover&lt;/strong&gt;&lt;br&gt;
Now let's make the image stretch to its full width, and I'll cover that empty space to the right.&lt;/p&gt;

&lt;p&gt;Add .bg-cover class to the image:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;!-- Background image --&amp;gt;&lt;br&gt;
&amp;lt;div&lt;br&gt;
  class="bg-cover bg-no-repeat"&lt;br&gt;
  style="height: 500px; background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;lt;!-- Background image --&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After saving the file, the image should stretch to its full available width.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Use bg-cover to scale the background image until it fills the background layer.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4 - scale the image to the full screen
&lt;/h2&gt;

&lt;p&gt;Now let's scale the image so that it takes up the entire screen area instead of 500px.&lt;/p&gt;

&lt;p&gt;Let's remove the hardcoded height of 500px, and add a .h-screen class instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;!-- Background image --&amp;gt;&lt;br&gt;
&amp;lt;div&lt;br&gt;
  class="h-screen bg-cover bg-no-repeat"&lt;br&gt;
  style="background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;lt;!-- Background image --&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After saving the file and &lt;strong&gt;refreshing the browser&lt;/strong&gt;, you will see that the image now covers the entire screen.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Use .h-screen to make an element span the entire height of the viewport.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;However, we have a problem. We wanted our image to cover exactly 100% of the available height, and for some reason a scroll bar appeared in the browser window. This means that our picture goes a little further than we wanted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau2d351wa2yifbvwufd2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau2d351wa2yifbvwufd2.gif" alt="Image description" width="515" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5 - fix the scroll
&lt;/h2&gt;

&lt;p&gt;If you look closely, you'll see that the image extends off the screen by exactly the height of our navbar - which is 56px .&lt;/p&gt;

&lt;p&gt;This is because to the 100% of the viewport height, set by the h-screen class, the Navbar added its height. So we have to take it into account and subtract it.&lt;/p&gt;

&lt;p&gt;To the image div let's add margin-top: -56px; . Thanks to this, the graphics will "slide" under the navbar exactly by its height and will be perfectly matched to the size of the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;!-- Background image --&amp;gt;&lt;br&gt;
&amp;lt;div&lt;br&gt;
  class="h-screen bg-cover bg-no-repeat"&lt;br&gt;
  style="margin-top: -56px; background-image: url('https://mdbcdn.b-cdn.net/img/new/fluid/city/018.jpg');"&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;lt;!-- Background image --&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After saving the file you will see the scroll is gone and now our hero image fills the screen perfectly.&lt;/p&gt;

&lt;p&gt;...almost perfectly 😕 there is a small bug on mobile screens, which we will take care of in the next lesson, and by the way we will learn another important aspect of Tailwind, called &lt;strong&gt;arbitrary values&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tw-elements.com/snippets/tailwind/ascensus/5324350"&gt;DEMO AND SOURCE CODE FOR THIS LESSON&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>learning</category>
      <category>html</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>TailwindCSS Dark Mode. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Tue, 25 Jun 2024 12:59:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/tailwindcss-dark-mode-free-uiux-design-course-3eb4</link>
      <guid>https://dev.to/keepcoding/tailwindcss-dark-mode-free-uiux-design-course-3eb4</guid>
      <description>&lt;h2&gt;
  
  
  Dark mode
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Psst!&lt;br&gt;
Press shift + D to toggle dark/light mode on most websites.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For some time now, dark mode has ceased to be just a fashionable novelty, and has become a mandatory functionality of good design.&lt;/p&gt;

&lt;p&gt;Thanks to Tailwind, the implementation of dark mode in our project is child's play.&lt;/p&gt;

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

&lt;p&gt;All we have to do is, as with Hover or other states, use the appropriate modifier and then specify the condition.&lt;/p&gt;

&lt;p&gt;The modifier for dark mode is keyword dark:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;div class="bg-white dark:bg-neutral-700"&amp;gt;[...]&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So if we want our standard, light card with dark text to have a dark mode variant, we need to define the condition that when dark mode is turned on, the background of the card changes to dark (dark:bg-neutral-700) and the text of the card to light (dark:text-neutral-50).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;div class="block rounded-lg bg-white p-6 shadow-md dark:bg-neutral-700"&amp;gt;&lt;br&gt;
  &amp;lt;h5&lt;br&gt;
    class="mb-2 text-xl font-medium leading-tight text-neutral-800 dark:text-neutral-50"&amp;gt;&lt;br&gt;
    Light mode&lt;br&gt;
  &amp;lt;/h5&amp;gt;&lt;br&gt;
  &amp;lt;p class="mb-4 text-base text-neutral-600 dark:text-neutral-200"&amp;gt;&lt;br&gt;
    Dark mode reduces eye strain in low-light conditions, saves energy on&lt;br&gt;
    OLED screens, and offers a visually refreshing aesthetic.&lt;br&gt;
  &amp;lt;/p&amp;gt;&lt;br&gt;
&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  System preferences
&lt;/h2&gt;

&lt;p&gt;Dark mode in Tailwind supports (in most cases) the preferences of your operating system.&lt;/p&gt;

&lt;p&gt;This means that Tailwind can detect whether you are using a dark or light theme on your computer and adapt to it.&lt;/p&gt;

&lt;p&gt;Therefore, depending on whether you used dark mode or light mode on your computer, our site should be displayed in your preferred mode from the beginning.&lt;/p&gt;

&lt;p&gt;That's just yet another cool feature of Tailwind CSS 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  Dark mode in the Navbar
&lt;/h2&gt;

&lt;p&gt;Take another look at the Navbar in our project.&lt;/p&gt;

&lt;p&gt;All the components of TW Elements support dark mode by default. So if you press shift + D on this website, you will notice that also the Navbar below switches the mode.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;!-- Navbar --&amp;gt;&lt;br&gt;
&amp;lt;nav&lt;br&gt;
  class="flex-no-wrap relative flex w-full items-center justify-between bg-white py-2 shadow-md shadow-black/5 dark:bg-neutral-600 dark:shadow-black/10 lg:flex-wrap lg:justify-start lg:py-4"&lt;br&gt;
  data-twe-navbar-ref&amp;gt;&lt;br&gt;
  [...]&lt;br&gt;
&amp;lt;/nav&amp;gt;&lt;br&gt;
&amp;lt;!-- Navbar --&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dark mode in the playground
&lt;/h2&gt;

&lt;p&gt;Whenever you see a button like this at the end of a lesson, you can go to our online editor to see the source code of the lesson material and modify it directly in your browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tw-elements.com/snippets/tailwind/ascensus/5284786"&gt;DEMO AND SOURCE CODE FOR THIS LESSON&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>learning</category>
      <category>html</category>
      <category>ui</category>
    </item>
    <item>
      <title>TW Elements - TailwindCSS Focus, active &amp; other states. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Mon, 24 Jun 2024 16:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/tw-elements-tailwindcss-focus-active-other-states-free-uiux-design-course-1jaa</link>
      <guid>https://dev.to/keepcoding/tw-elements-tailwindcss-focus-active-other-states-free-uiux-design-course-1jaa</guid>
      <description>&lt;h2&gt;
  
  
  Focus, active and other states
&lt;/h2&gt;

&lt;p&gt;Hover isn't the only state supported by Tailwind CSS.&lt;/p&gt;

&lt;p&gt;Thanks to Tailwind we can use directly in our HTML any state available in regular CSS.&lt;/p&gt;

&lt;p&gt;Below are examples of several pseudo-class states supported in Tailwind CSS.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You don't have to try to memorize them now, we'll cover them in detail in the next lessons. For now, just be aware of their existence so you won't be surprised if you spot them in some TW Elements component.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Focus:&lt;/strong&gt; Applied when an element has the focus. It is also enabled by default in Tailwind CSS. The modifier used is &lt;em&gt;focus:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Active:&lt;/strong&gt; Applied when an element is being activated by the user. The modifier used is &lt;em&gt;active:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Visited:&lt;/strong&gt; Applied once a user has visited a link. The modifier used is &lt;em&gt;visited:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Disabled:&lt;/strong&gt; Applied when an element is disabled. The modifier used is &lt;em&gt;disabled:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Group-hover and group-focus:&lt;/strong&gt; These are special states in Tailwind CSS that are used to apply styles to one element when another element is hovered or focused. They are typically used with the group utility class. The modifiers used are &lt;em&gt;group-hover:&lt;/em&gt; and &lt;em&gt;group-focus:&lt;/em&gt; respectively.&lt;br&gt;
&lt;strong&gt;First-child and last-child:&lt;/strong&gt; Applied to the first or last child of its parent. The modifiers used are &lt;em&gt;first:&lt;/em&gt; and &lt;em&gt;last:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Even and odd:&lt;/strong&gt; Applied to even or odd children of its parent. The modifiers used are &lt;em&gt;even:&lt;/em&gt; and &lt;em&gt;odd:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Dark:&lt;/strong&gt; Applied when dark mode is active. The modifier used is &lt;em&gt;dark:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Placeholder:&lt;/strong&gt; Applied to style placeholder text in form inputs. The modifier used is &lt;em&gt;placeholder:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Checked:&lt;/strong&gt; Applied when a checkbox or radio button is checked. The modifier used is &lt;em&gt;checked:&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Focus-within:&lt;/strong&gt; Applied when an element itself has focus or contains an element that has focus. The modifier used is &lt;em&gt;focus-within:&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Using multiple states
&lt;/h2&gt;

&lt;p&gt;There is no problem in Tailwind if you want to use multiple states in one element.&lt;/p&gt;

&lt;p&gt;A good example is a simple button that must handle both hover, focus, active, dark, and sometimes other states.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8b8n0cf3tw692jkt8ly.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8b8n0cf3tw692jkt8ly.gif" alt="Image description" width="800" height="123"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And here is the button code:&lt;br&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;a
  href="#"
  target="_blank"
  role="button"
  data-twe-ripple-init
  data-twe-ripple-color="light"
  class="mb-4 inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong"&amp;gt;
  Primary
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I know, it looks disturbing. The amount of classes in HTML raises concerns about being too cluttered, but it's another thing you just have to get used to in Tailwind.&lt;/p&gt;

&lt;p&gt;Anyway, note that we can apply any modifiers to our button to handle any states.&lt;/p&gt;

&lt;p&gt;We just add them side by side:&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="bg-blue-500 hover:bg-red-400 focus:bg-yellow-600 active:bg-green-700"&amp;gt;
  Random element
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Multiple states in the Navbar
&lt;/h2&gt;

&lt;p&gt;Take another look at the Navbar in our project.&lt;/p&gt;

&lt;p&gt;When you hover over a link on the left or an icon on the right, the color will change. However, when you move the cursor away, the color returns to its original. Thanks to the &lt;em&gt;hover:&lt;/em&gt; modifier.&lt;/p&gt;

&lt;p&gt;However, if you click on a specific link or icon and then move the cursor away, the changed color will remain the same until you unclick somewhere else on the page. Thanks to the &lt;em&gt;focus:&lt;/em&gt; modifier.&lt;/p&gt;

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

&lt;p&gt;So if you look closely at the sample link in our Navbar, you'll see that we use different modifiers here to handle different states:&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;a
  class="text-neutral-500 hover:text-neutral-700 focus:text-neutral-700 disabled:text-black/30 dark:text-neutral-200 dark:hover:text-neutral-300 dark:focus:text-neutral-300 lg:px-2 [&amp;amp;.active]:text-black/90 dark:[&amp;amp;.active]:text-zinc-400"
  href="#"
  data-twe-nav-link-ref
  &amp;gt;Dashboard&amp;lt;/a
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You probably noticed there, in addition to modifiers such as focus: or &lt;em&gt;active:&lt;/em&gt;, also the modifier &lt;em&gt;dark:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It is used to support the famous dark mode, which we will deal with in the next lesson.&lt;/p&gt;

</description>
      <category>tailkwind</category>
      <category>design</category>
      <category>html</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>TW Elements - TailwindCSS Hover state. Free UI/UX design course</title>
      <dc:creator>Keep Coding</dc:creator>
      <pubDate>Wed, 19 Jun 2024 11:00:00 +0000</pubDate>
      <link>https://dev.to/keepcoding/tw-elements-tailwindcss-hover-state-free-uiux-design-course-2o9f</link>
      <guid>https://dev.to/keepcoding/tw-elements-tailwindcss-hover-state-free-uiux-design-course-2o9f</guid>
      <description>&lt;h2&gt;
  
  
  Hover state
&lt;/h2&gt;

&lt;p&gt;The thing where Tailwind CSS really shines is applying different CSS states, like hover, to our UI elements.&lt;/p&gt;

&lt;p&gt;The hover state in Tailwind is used to apply styles to an element when the mouse pointer is over it. This is similar to the :hover pseudo-class in CSS.&lt;/p&gt;

&lt;p&gt;Hover over the rectangle below and it will turn from blue to red.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn6403kleut0e23z6rg9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn6403kleut0e23z6rg9.gif" alt="Image description" width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Hover in regular CSS
&lt;/h2&gt;

&lt;p&gt;To achieve this effect in regular CSS, we would need to apply code like the following:&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;#rectangle {
  background-color: blue;
}
#rectangle:hover {
  background-color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course we would also need to add the id #rectangle to the HTML element to specify where exactly our CSS should be applied.&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 id="rectangle"&amp;gt;Hover me&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Hover in Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;In Tailwind it's easier. We just need to add a modifier hover: to the beginning of the class name and then specify what should happen when the user hovers the element.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; Modifier is a keyword that you append to a utility class to alter its behaviour or style.&lt;/em&gt;&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="bg-blue-500 hover:bg-red-500"&amp;gt;Hover me&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the above example, by default our element is blue (.bg-blue-500 class), but when we hover it, it changes to red (.bg-red-500 class).&lt;/p&gt;

&lt;p&gt;hover: works like an "if".&lt;/p&gt;

&lt;p&gt;It's simply a condition, which says "If the user hovers over this element, change the color to bg-red-500 " .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using multiple classes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We are not limited to using only one class when we want to use hover:&lt;/p&gt;

&lt;p&gt;We can use them as much as we want.&lt;/p&gt;

&lt;p&gt;For example, let's assume that in addition to the background color, we also want to change the color of the text and padding of our element on the hover.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwc9hu1y8dl4jslo1aq1e.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwc9hu1y8dl4jslo1aq1e.gif" alt="Image description" width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To achieve this, we just need to add more hover: modifiers along with the next classes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt; that each class has its own hover: modifier: We cannot add more than one class to one modifier.&lt;/em&gt;&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="bg-blue-500 p-5 text-white hover:bg-red-500 hover:p-7 hover:text-green-500"&amp;gt;
  Hover me
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Hover state in the Navbar&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the Navbar, which we finished in the previous lesson, we use the hover modifier a lot.&lt;/p&gt;

&lt;p&gt;Hover over the links on the left or the icons on the right and you'll see them slightly change their color.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F997ppvrrg0qfoe8pnh8j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F997ppvrrg0qfoe8pnh8j.gif" alt="Image description" width="800" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is of course due to the use of the hover: modifier. If you look closely, you'll see that it's present in every link:&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;a
  class="text-neutral-500 hover:text-neutral-700 focus:text-neutral-700 disabled:text-black/30 dark:text-neutral-200 dark:hover:text-neutral-300 dark:focus:text-neutral-300 lg:px-2 [&amp;amp;.active]:text-black/90 dark:[&amp;amp;.active]:text-zinc-400"
  href="#"
  data-twe-nav-link-ref
  &amp;gt;Dashboard&amp;lt;/a
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To sum up - using the hover state in Tailwind may seem strange at first, but it's actually very simple once you get used to it.&lt;/p&gt;

&lt;p&gt;You've probably noticed other modifiers in the Navbar, such as &lt;em&gt;focus:&lt;/em&gt; and &lt;em&gt;disabled:&lt;/em&gt;. We'll cover them in the next lesson.&lt;/p&gt;

</description>
      <category>bootstrap</category>
      <category>learning</category>
      <category>css</category>
      <category>html</category>
    </item>
  </channel>
</rss>
