<?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: Amin Raeisi</title>
    <description>The latest articles on DEV Community by Amin Raeisi (@codepromax).</description>
    <link>https://dev.to/codepromax</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%2F917709%2F8d973f89-3872-40fa-8947-d8e1540cba4e.png</url>
      <title>DEV Community: Amin Raeisi</title>
      <link>https://dev.to/codepromax</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codepromax"/>
    <language>en</language>
    <item>
      <title>Colors in Tailwind CSS</title>
      <dc:creator>Amin Raeisi</dc:creator>
      <pubDate>Wed, 30 Nov 2022 15:00:00 +0000</pubDate>
      <link>https://dev.to/codepromax/colors-in-tailwind-css-5blf</link>
      <guid>https://dev.to/codepromax/colors-in-tailwind-css-5blf</guid>
      <description>&lt;p&gt;Tailwind CSS has its own color system. At the time of writing this article, Tailwind CSS provides 22 color names, each with 10 different shades. Shade number 50 is the lightest and shade number 900 is the darkest shade of each color. So a total of 220 “expertly-crafted” colors to choose from. We can apply colors to text, backgrounds, borders, shadows, and more.&lt;/p&gt;

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

&lt;p&gt;Tailwind CSS provides utility classes for colors. The naming convention for these classes is simple and easy to remember.&lt;/p&gt;

&lt;p&gt;For example, if we want to set the text color of an element to red with the shade of 500, the class to add to the element will be &lt;code&gt;text-red-500&lt;/code&gt;. If we want to set the background color of an element to green with the shade of 300, the class to add will be &lt;code&gt;bg-green-300&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red-500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-green-300"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also have the colors black and white which we use without a shade number (e.g., &lt;code&gt;text-black&lt;/code&gt; or &lt;code&gt;bg-white&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Tailwind CSS Text Color
&lt;/h2&gt;

&lt;p&gt;As I mentioned, the class naming convention for changing the text color is:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Let's go to the &lt;a href="https://play.tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind Play&lt;/a&gt; website and try it there. Remove all the code in the editor section so that we get a blank screen.&lt;/p&gt;

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

&lt;p&gt;Add the following 3 paragraph elements to the page. Notice that I have a random text in each one. You can insert random text by typing "lorem" and then hitting the &lt;code&gt;TAB&lt;/code&gt; key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat culpa alias atque est vel iusto aliquid, suscipit quos nobis laboriosam impedit quam ipsum fugit quisquam vitae nostrum, hic deserunt modi!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Repellat minima deleniti eaque voluptatibus? Deserunt aperiam officiis architecto atque omnis eius commodi dolorem, iusto, autem maiores in numquam, tempore consequuntur. Odit!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Temporibus error optio veniam cumque veritatis dolore perspiciatis deleniti consectetur adipisci eligendi dignissimos, doloribus vero totam nisi repellendus quisquam. Nam, corrupti nostrum.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the result, and we can see that we do not have any styles applied to the paragraphs yet.&lt;/p&gt;

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

&lt;p&gt;if we add the class &lt;code&gt;text-red-500&lt;/code&gt; to the first paragraph, we can see that the color changes to red.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red-500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat culpa alias atque est vel iusto aliquid, suscipit quos nobis laboriosam impedit quam ipsum fugit quisquam vitae nostrum, hic deserunt modi!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Add the classes &lt;code&gt;text-green-800&lt;/code&gt; and &lt;code&gt;text-green-300&lt;/code&gt; to the second and third paragraphs and check the result. Here is how our code looks like now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red-500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat culpa alias atque est vel iusto aliquid, suscipit quos nobis laboriosam impedit quam ipsum fugit quisquam vitae nostrum, hic deserunt modi!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-800"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Repellat minima deleniti eaque voluptatibus? Deserunt aperiam officiis architecto atque omnis eius commodi dolorem, iusto, autem maiores in numquam, tempore consequuntur. Odit!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-300"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Temporibus error optio veniam cumque veritatis dolore perspiciatis deleniti consectetur adipisci eligendi dignissimos, doloribus vero totam nisi repellendus quisquam. Nam, corrupti nostrum.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h2&gt;
  
  
  Tailwind CSS Background Color
&lt;/h2&gt;

&lt;p&gt;The class naming convention for changing the background color is:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Let's give each of our paragraphs different background colors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red-500 bg-gray-900"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-800 bg-green-50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-300 bg-yellow-900"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the result, and we can see that the background colors have changed.&lt;/p&gt;

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

&lt;p&gt;Easy, right? Tailwind CSS provides a similar naming convention for other color utility classes. I will cover those in the coming posts where we need to use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing Colors in Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;Before we add custom colors, I need to show you how CSS colors work. In the preview section, &lt;code&gt;right click&lt;/code&gt; on the first paragraph and select &lt;code&gt;Inspect&lt;/code&gt;.&lt;/p&gt;

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

&lt;p&gt;This will open the &lt;a href="//../html-common-elements-headings-and-text-html-basics-02/#chrome-developer-tools-devtools"&gt;Chrome DevTools&lt;/a&gt;. On the left side, make sure that the first &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element is selected.  On the right side under the &lt;code&gt;Styles&lt;/code&gt; tab, look for the &lt;code&gt;.text-red-500&lt;/code&gt; and &lt;code&gt;.bg-gray-900&lt;/code&gt; classes.&lt;/p&gt;

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

&lt;p&gt;You can see that the easy-to-remember class names are setting the colors in a way that the browser understands. in both &lt;code&gt;text-red-500&lt;/code&gt; and &lt;code&gt;bg-gray-900&lt;/code&gt; classes, the value of the color is applied using the &lt;code&gt;rgb()&lt;/code&gt; color value.  The RGB color value is one of the many ways that we define colors in CSS. Some of the popular ways are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hexadecimal: starts with &lt;code&gt;#&lt;/code&gt; and has different length (e.g., white is &lt;code&gt;#FFF&lt;/code&gt; or &lt;code&gt;#FFFFFF&lt;/code&gt; and black is &lt;code&gt;#000&lt;/code&gt; or &lt;code&gt;#000000&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;RGB: represents RED, GREEN, and BLUE color values. Each color value is between 0 and 255 where 255 has the most intensity (e.g., white is &lt;code&gt;rgb(255,255,255)&lt;/code&gt; and black is &lt;code&gt;rgb(0,0,0)&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;RGBA: similar to RGB but with one more value at the end which is for the opacity and it is between 0 and 1 (e.g., &lt;code&gt;rgba(255,0,0,0.5)&lt;/code&gt; is color red at 50% opacity)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As I mentioned before, Tailwind CSS has more than 220 color shades. But if you want to pick a color of your choice, Tailwind CSS provides a few different ways to do that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Arbitrary Values
&lt;/h3&gt;

&lt;p&gt;If you want to use a custom color in a few places, you can use arbitrary values. The naming convention for color classes with arbitrary values is not that different. Instead of the color and shade names, we write the CSS color value wrapped with square brackets &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here are a few examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* change background color to #ff7947 */&lt;/span&gt;
&lt;span class="nt"&gt;bg-&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;#ff7947&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="c"&gt;/* change background color to rgb(255, 99, 71) */&lt;/span&gt;
&lt;span class="nt"&gt;bg-&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;rgb&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;99&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;71&lt;/span&gt;&lt;span class="o"&gt;)]&lt;/span&gt;
&lt;span class="c"&gt;/* change text color to #ff7947 */&lt;/span&gt;
&lt;span class="nt"&gt;text-&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;#ff7947&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="c"&gt;/* change text color to rgb(255, 99, 71) */&lt;/span&gt;
&lt;span class="nt"&gt;text-&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;rgb&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;99&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;71&lt;/span&gt;&lt;span class="o"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's add two more paragraphs, one with text color &lt;code&gt;#ff7947&lt;/code&gt; and the other one with a background color of &lt;code&gt;rgb(255,99,71)&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-[#ff7947]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Labore ut itaque deserunt voluptatibus nisi quo in modi nemo ducimus culpa, corporis ipsa quisquam? Numquam ad porro rerum ipsam atque necessitatibus.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-[rgb(255,99,71)]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias consequatur commodi veritatis dignissimos explicabo enim error voluptatum corrupti, aspernatur optio voluptatem eveniet beatae esse expedita et ad. Laborum, natus ratione?&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the result and we can see that both colors are applied.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Adding Additional Colors
&lt;/h3&gt;

&lt;p&gt;Tailwind CSS allows us to extend the default color palette. We can add new colors or even add colors with different shades. As you already know, Tailwind CSS has a config file called &lt;code&gt;tailwind.config.js&lt;/code&gt;.  Tailwind Play has the config file under the &lt;code&gt;Config&lt;/code&gt; tab.&lt;/p&gt;

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

&lt;p&gt;First, we need to add a new object called &lt;code&gt;colors&lt;/code&gt; within the &lt;code&gt;extend&lt;/code&gt; object.&lt;/p&gt;

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

&lt;p&gt;Any &lt;code&gt;key: value&lt;/code&gt; pair we add inside the &lt;code&gt;colors&lt;/code&gt; object represents a color. Let's add a new color called &lt;code&gt;sea&lt;/code&gt; with the value &lt;code&gt;#2D7AFF&lt;/code&gt;. We need to add the value as a string (wrapped with &lt;code&gt;'&lt;/code&gt; or &lt;code&gt;"&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** @type {import('tailwindcss').Config} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;sea&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#2D7AFF&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now the new color &lt;code&gt;sea&lt;/code&gt; can be applied to our pages. If we want it for text color, we use &lt;code&gt;text-sea&lt;/code&gt;, or if we want it for background color, we use &lt;code&gt;bg-sea&lt;/code&gt; class. Let's change the last paragraph's text color to the color &lt;code&gt;sea&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red-500 bg-gray-900"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-800 bg-green-50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-300 bg-yellow-900"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-[#ff7947]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-[rgb(255,99,71)] text-sea"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h3&gt;
  
  
  Adding Colors With Shades
&lt;/h3&gt;

&lt;p&gt;We can also add custom colors with different shades like Tailwind CSS colors. We can do that by setting the value of the color key as an object that has &lt;code&gt;key: value&lt;/code&gt; pairs. Each of those &lt;code&gt;key: value&lt;/code&gt; pairs will represent a color shade.&lt;/p&gt;

&lt;p&gt;Let's say we want to add a new color called &lt;code&gt;warm&lt;/code&gt; and it has 3 different shades. The color values for the 3 shades are &lt;code&gt;#FF0000&lt;/code&gt;, &lt;code&gt;#B80000&lt;/code&gt;, and &lt;code&gt;#6D0000&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;We can name each shade anything we like. We can name them like Tailwind CSS (numbers between &lt;code&gt;50&lt;/code&gt; and &lt;code&gt;900&lt;/code&gt;) or we can name them with words. Let's go with the second option and name them &lt;code&gt;lightest&lt;/code&gt;, &lt;code&gt;normal&lt;/code&gt;, and &lt;code&gt;darkest&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** @type {import('tailwindcss').Config} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;sea&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#2D7AFF&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;warm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;lightest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#FF0000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#B80000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;darkest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#6D0000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Now that the color &lt;code&gt;warm&lt;/code&gt; has been added, let's use it as the background color of the fourth paragraph.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red-500 bg-gray-900"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-800 bg-green-50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-green-300 bg-yellow-900"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-[#ff7947] bg-warm-darkest"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-[rgb(255,99,71)] text-sea"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the result and we can see that the background color is changed.&lt;/p&gt;

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

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>How to Install Tailwind CSS: Explained!</title>
      <dc:creator>Amin Raeisi</dc:creator>
      <pubDate>Thu, 01 Sep 2022 03:55:18 +0000</pubDate>
      <link>https://dev.to/codepromax/how-to-install-tailwind-css-explained-13ai</link>
      <guid>https://dev.to/codepromax/how-to-install-tailwind-css-explained-13ai</guid>
      <description>&lt;p&gt;This post is the beginner's guide on how to install Tailwind CSS using the Tailwind CLI. There are many ways you can install Tailwind CSS and it all depends on what kind of project you are working on.&lt;/p&gt;

&lt;p&gt;Before we get started, there are a few points you might need to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you want to try Tailwind CSS, &lt;a href="https://play.tailwindcss.com/"&gt;Tailwind Play&lt;/a&gt; and &lt;a href="https://tailwindcss.com/docs/installation/play-cdn"&gt;Play CDN&lt;/a&gt; are the quickest way you can get your hands dirty&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When installing Tailwind CSS on a framework, there might be some differences. Check the &lt;a href="https://tailwindcss.com/docs/installation/framework-guides"&gt;framework guides&lt;/a&gt; section to find the installation for your framework. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TLDR: &lt;a href="https://tailwindcss.com/docs/installation"&gt;https://tailwindcss.com/docs/installation&lt;/a&gt;  &lt;strong&gt;&lt;code&gt;¯\_(ツ)_/¯&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Install Tailwind CSS using Tailwind CLI
&lt;/h2&gt;

&lt;p&gt;The first thing we need is &lt;code&gt;npm&lt;/code&gt;. NPM is a package manager for JavaScript. Think about a package manager as a way you can manage other people's code inside your project. The reason we need it is to be able to use the &lt;code&gt;tailwindcss&lt;/code&gt; package in our project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Node.js and npm
&lt;/h3&gt;

&lt;p&gt;To have npm, we need to install it through installing Node.js. First, we need to check if we have Node.js and npm installed. Open the command prompt (or PowerShell/Terminal/etc.), and enter the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-v&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the system shows you the version number for node, then you already have node installed. You can do the same to verify npm installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-v&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FOSuOfuR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8784raz09zdpe2mt8dop.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FOSuOfuR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8784raz09zdpe2mt8dop.jpg" alt="Node.js and npm Version" width="880" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don't get the version number for node and npm, then you need to install Node.js. Go to &lt;a href="https://nodejs.org/"&gt;nodejs.org&lt;/a&gt; and depending on your Operating System, install the LTS version.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4JnWxvpt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0o2l0p9geygfgwdi5mp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4JnWxvpt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0o2l0p9geygfgwdi5mp.jpg" alt="Node.js website" width="880" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create the Project Directory
&lt;/h3&gt;

&lt;p&gt;Inside the desktop, create a folder called &lt;code&gt;website&lt;/code&gt;. Inside the &lt;code&gt;website&lt;/code&gt; folder, create a folder called &lt;code&gt;src&lt;/code&gt; which we will use to store our website files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RAtvdj4Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eoia6oi8mosixf07t21d.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RAtvdj4Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eoia6oi8mosixf07t21d.JPG" alt="Project Directory" width="754" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Install &lt;code&gt;tailwindcss&lt;/code&gt; package
&lt;/h3&gt;

&lt;p&gt;Using the command prompt, go to the project directory (&lt;code&gt;website&lt;/code&gt; folder). In my case I will enter &lt;code&gt;cd .\Desktop\website&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v1sxToKD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k47hax7w5o0n2w3m642j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v1sxToKD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k47hax7w5o0n2w3m642j.jpg" alt="Changing directory to project root" width="803" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the following to install the &lt;code&gt;tailwindcss&lt;/code&gt; package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-D&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwindcss&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first two words &lt;code&gt;npm install&lt;/code&gt; will use npm to install a package. The flag &lt;code&gt;-D&lt;/code&gt; tells npm to only install the package in development and not in production. The last part &lt;code&gt;tailwindcss&lt;/code&gt; is the package name.&lt;/p&gt;

&lt;p&gt;If we open the project folder in VS Code, there is a new folder called &lt;code&gt;node_modules&lt;/code&gt;. &lt;code&gt;node_modules&lt;/code&gt; folder is where all the external packages will be saved. If we look into the folder, we can see that there is a &lt;code&gt;tailwindcss&lt;/code&gt; folder that contains the &lt;code&gt;tailwindcss&lt;/code&gt; code. The good news is that we do not change anything in this folder and all changes happen with npm commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Z8F6VOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2440nb99yctruu3d5ez1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Z8F6VOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2440nb99yctruu3d5ez1.jpg" alt="VS Code view of the new files" width="553" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The files &lt;code&gt;package.json&lt;/code&gt; and &lt;code&gt;package-lock.json&lt;/code&gt; are also created. &lt;code&gt;package.json&lt;/code&gt; file contains information about the project with the packages it uses. &lt;code&gt;package-lock.json&lt;/code&gt; contains the packages with the exact version numbers installed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tailwind CSS Config File
&lt;/h3&gt;

&lt;p&gt;Next, create a Tailwind CSS config file using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwindcss&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; is similar to &lt;code&gt;npm&lt;/code&gt; but we use it to execute packages. The command we ran, created a new config file called &lt;code&gt;tailwind.config.js&lt;/code&gt;. The config file contains a boilerplate of the Tailwind CSS configuration. Inside the config file, we have a JavaScript object with a few properties.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FLcgWNsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywg05kcdy8zg1ym12epu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FLcgWNsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywg05kcdy8zg1ym12epu.jpg" alt="Tailwind CSS config file" width="732" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can configure a lot of things with the config file. For now, the only important part of the config file is the &lt;code&gt;content&lt;/code&gt; property. The &lt;code&gt;content&lt;/code&gt; property is the way to tell &lt;code&gt;tailwindcss&lt;/code&gt; what files to look for when it wants to build our CSS file.&lt;/p&gt;

&lt;p&gt;So in our case, we want &lt;code&gt;tailwindcss&lt;/code&gt; to scan all &lt;code&gt;.html&lt;/code&gt; files inside the &lt;code&gt;src&lt;/code&gt; folder. The syntax for that will be the string &lt;code&gt;"./src/**/*.html"&lt;/code&gt;. Let's break down the path so that you know what is going on here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.&lt;/code&gt;: Start from the current path/folder (the root of the project)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/src&lt;/code&gt;: Look inside the &lt;code&gt;src/&lt;/code&gt; folder&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/**/&lt;/code&gt;: Look within all subfolders within the parent folder (&lt;code&gt;src/&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*.html&lt;/code&gt;: The files we want are files with any name (&lt;code&gt;*&lt;/code&gt;) but with &lt;code&gt;.html&lt;/code&gt; file extension only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So here is the final code of our config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** @type {import('tailwindcss').Config} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/**/*.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tailwind CSS directives
&lt;/h3&gt;

&lt;p&gt;Directives are different parts of Tailwind CSS. We can also register new directives with the use of plugins. Three main directives are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;base&lt;/code&gt;&lt;/strong&gt;: Injects Tailwind CSS base styles and registered plugins' styles&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;components&lt;/code&gt;&lt;/strong&gt;: Injects Tailwind CSS component classes and registered plugins' component classes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;utilities&lt;/code&gt;&lt;/strong&gt;: Injects Tailwind CSS utility classes and registered plugins' utility classes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Inside the &lt;code&gt;src/&lt;/code&gt; folder, create a file called &lt;code&gt;style.css&lt;/code&gt;. The name of the file does not matter. Tailwind CSS uses this file as input to build the actual CSS file that contains the CSS styles we need.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code&gt;style.css&lt;/code&gt; file, add the Tailwind CSS directives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Building The CSS File
&lt;/h3&gt;

&lt;p&gt;Using the command prompt enter the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwindcss&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;/src/style.css&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-o&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;/src/css/main.css&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npx tailwindcss&lt;/code&gt;: Executes the build command&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-i ./src/style.css&lt;/code&gt;: The flag &lt;code&gt;-i&lt;/code&gt; tells the &lt;code&gt;tailwindcss&lt;/code&gt; package what is the &lt;code&gt;input&lt;/code&gt; file (&lt;code&gt;./src/style.css&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-o ./src/css/main.css&lt;/code&gt;: The flag &lt;code&gt;-o&lt;/code&gt; tells the &lt;code&gt;tailwindcss&lt;/code&gt; package what is the &lt;code&gt;output&lt;/code&gt; file (&lt;code&gt;./src/css/main.css&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check the project files and we can see that our &lt;code&gt;main.css&lt;/code&gt; file got built. This is the file that we will import into our HTML file. Right now, the &lt;code&gt;main.css&lt;/code&gt; only contains the &lt;code&gt;base&lt;/code&gt; styles. This is because we do not have any HTML page for Tailwind to scan and add the used component or utility classes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pH5Eh4HK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cm15pazwib1a9buxlrr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pH5Eh4HK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cm15pazwib1a9buxlrr.jpg" alt="main.css File" width="273" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Use the Tailwind CSS Output File in HTML
&lt;/h3&gt;

&lt;p&gt;Inside the &lt;code&gt;src/&lt;/code&gt; folder, create a file called &lt;code&gt;index.html&lt;/code&gt;. Import the &lt;code&gt;main.css&lt;/code&gt; file and add a simple button with some Tailwind CSS classes to test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Tailwind CSS&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"css/main.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-lg text-red-500 bg-red-200"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;CodeProMax&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and check the result. If you have the &lt;a href="https://codepromax.co/blog/html-common-elements-headings-and-text-html-basics-02/#live-server-extension"&gt;live server extension&lt;/a&gt; installed like me, you can open the file with the live server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hGdTv_Yp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icbute4fycu83hmocpzk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hGdTv_Yp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icbute4fycu83hmocpzk.jpg" alt="Result Page" width="553" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The button did not get any of the styles we applied to. If we check the &lt;code&gt;main.css&lt;/code&gt; file, we can see that it does not contain the utility classes we applied to the button. This is because every time we make a change to the classes, Tailwind CSS needs to build the &lt;code&gt;main.css&lt;/code&gt; file with the latest update.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SQ9fwNVJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulwbp91vmereeokpkd7a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SQ9fwNVJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulwbp91vmereeokpkd7a.jpg" alt="main.css file without styles" width="802" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To understand the process better, here is how Tailwind CSS works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vBsV2a4C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5b72qaajyiyhzdyi356k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vBsV2a4C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5b72qaajyiyhzdyi356k.png" alt="How Tailwind CSS works" width="563" height="975"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To generate the classes we need to run the build command again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwindcss&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;/src/style.css&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-o&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;/src/css/main.css&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we check the page now, we can see that our button has got the styles applied to:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BBs35WJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sa8l6h3w4rady9qcb6xr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BBs35WJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sa8l6h3w4rady9qcb6xr.jpg" alt="Result Page" width="553" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Running the same build command for every change is not a good flow. We can automate that by adding the &lt;code&gt;--watch&lt;/code&gt; flag to the build command. So here is the build command with the &lt;code&gt;watch&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwindcss&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;/src/style.css&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-o&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;/src/css/main.css&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--watch&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can notice that the command prompt did not finish or stop and it is still active. The &lt;code&gt;watch&lt;/code&gt; flag keeps the command prompt active and "watches" the files for any change. Once it detects a change, it will run the build command automatically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vm8fmqKV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcsvef3670d0lg3l501o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vm8fmqKV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcsvef3670d0lg3l501o.jpg" alt="Tailwind CSS Build Command with Watch Flag" width="880" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While the command prompt is still active, let's add a new class &lt;code&gt;font-extrabold&lt;/code&gt; to the button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Tailwind CSS&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"css/main.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-lg text-red-500 bg-red-200 font-extrabold"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;CodeProMax&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file, refresh, and we can see the new changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--os4nMIkG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71mflhoozyp60c1apo8c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--os4nMIkG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71mflhoozyp60c1apo8c.jpg" alt="Result Page" width="559" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you check the &lt;code&gt;mian.css&lt;/code&gt; file, we can see that the class &lt;code&gt;font-extrabold&lt;/code&gt; is now added to the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iT5tjUJX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymzap0nd7y98g0cevz1p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iT5tjUJX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymzap0nd7y98g0cevz1p.jpg" alt="main.css File Updated" width="740" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Tailwind CSS Flow
&lt;/h3&gt;

&lt;p&gt;The things we covered in this post are not your everyday flow using Tailwind CSS. Most of the time you run the build command with the &lt;code&gt;watch&lt;/code&gt; flag, and continue working on your project.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tailwindcss</category>
      <category>beginners</category>
      <category>css</category>
    </item>
    <item>
      <title>Prerequisites for Learning Tailwind CSS</title>
      <dc:creator>Amin Raeisi</dc:creator>
      <pubDate>Tue, 30 Aug 2022 04:42:45 +0000</pubDate>
      <link>https://dev.to/codepromax/prerequisites-for-learning-tailwind-css-pdh</link>
      <guid>https://dev.to/codepromax/prerequisites-for-learning-tailwind-css-pdh</guid>
      <description>&lt;p&gt;In this article, we will go through the minimum CSS knowledge you need to know before starting with &lt;a href="https://tailwindcss.com/"&gt;Tailwind CSS&lt;/a&gt;. I assume that you already know the &lt;a href="https://codepromax.co/blog/html-introduction-elements-and-tags-html-basics-01"&gt;basics of HTML&lt;/a&gt;. But if you don't, I have written a blog series covering that &lt;a href="https://codepromax.co/blog/html-introduction-elements-and-tags-html-basics-01"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is CSS?
&lt;/h2&gt;

&lt;p&gt;CSS stands for &lt;strong&gt;Cascading Style Sheets&lt;/strong&gt;. CSS is not a programming language. CSS applies the style to the HTML elements and changes the way they look on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Syntax
&lt;/h2&gt;

&lt;p&gt;Here is an example of a CSS syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So let's break it down to understand it better. We have the &lt;code&gt;h1&lt;/code&gt; which is the &lt;strong&gt;selector&lt;/strong&gt;. The selector points to the element we want to style, in this case, all the &lt;code&gt;h1&lt;/code&gt; elements. Each line within the curly braces &lt;code&gt;{}&lt;/code&gt; contains a &lt;strong&gt;declaration&lt;/strong&gt; (each declaration contains &lt;code&gt;property: value;&lt;/code&gt;).  The first declaration has the &lt;strong&gt;property&lt;/strong&gt; &lt;code&gt;color&lt;/code&gt; set to &lt;strong&gt;value&lt;/strong&gt; &lt;code&gt;red&lt;/code&gt;. The second declaration has the property &lt;code&gt;font-size&lt;/code&gt; set to value &lt;code&gt;16px&lt;/code&gt;. The semicolon &lt;code&gt;;&lt;/code&gt; comes at the end of each of the declarations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZSu8D3ld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1yuxgna4pvm78oqsb31.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZSu8D3ld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1yuxgna4pvm78oqsb31.jpg" alt="CSS Syntax" width="397" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the CSS code above, all the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; elements within the page will get the text color of red and the font size of 16 pixels.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use CSS?
&lt;/h2&gt;

&lt;p&gt;Let's create a folder called "website" on the desktop and open that with your text editor. Inside the folder, create a file called &lt;code&gt;index.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6PQQRHmc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqoi990lv0sgxde04wld.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6PQQRHmc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqoi990lv0sgxde04wld.jpeg" alt="Project directory" width="754" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the following code to the &lt;code&gt;index.html&lt;/code&gt; page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Zero CSS to Tailwind CSS&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can add CSS to our page in three ways:&lt;/p&gt;

&lt;h3&gt;
  
  
  Inline CSS
&lt;/h3&gt;

&lt;p&gt;In this method, we set the value of the &lt;code&gt;style&lt;/code&gt; attribute on an element to the CSS declarations we want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color:red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Code Pro Max&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert the above &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element inside the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; of the page and check the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q9q9xxlg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afw4xqnkf64qsa9onjlf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q9q9xxlg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afw4xqnkf64qsa9onjlf.jpg" alt="Inline CSS" width="309" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is not recommended to use inline CSS because you need to specify all the styles needed for every single element and there is no reusability of your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Internal CSS
&lt;/h3&gt;

&lt;p&gt;We can insert an internal CSS inside the head element of our page. We wrap the CSS code with a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag. Let's add a paragraph to the page and apply a style to it using the internal CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Zero CSS to Tailwind CSS&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color:red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Code Pro Max&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is the main website for Code Pro Max.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that the internal CSS syntax is a bit different and that is because the CSS declarations applied needs a selector to point to an element. The first part of the syntax (&lt;code&gt;p&lt;/code&gt;) points to all &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements within the page. Then all the CSS declarations we have within the curly braces &lt;code&gt;{}&lt;/code&gt; will get applied to the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8a1k7uzL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9trgs6ngow4hcu6tn32u.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8a1k7uzL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9trgs6ngow4hcu6tn32u.jpg" alt="Internal CSS" width="393" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The limitation of this method is that, you have to recreate the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; section for every single page you have to reuse the styles on other pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  External CSS
&lt;/h3&gt;

&lt;p&gt;The external CSS method is similar to the internal styles but with the difference of the styles are written in a separate &lt;code&gt;.css&lt;/code&gt; file so that it is easier to reuse the styles on any page you need.&lt;/p&gt;

&lt;p&gt;Add the following after the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element in our &lt;code&gt;index.html&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Blog Posts&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;Recent Blog Posts&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file called &lt;code&gt;style.css&lt;/code&gt; and write the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;h3&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CSS style we have written sets all the &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; tag's text color to &lt;code&gt;blue&lt;/code&gt; and applies a font size of &lt;code&gt;50 pixels&lt;/code&gt; to all &lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt; elements.&lt;/p&gt;

&lt;p&gt;But how can we tell the html page about this external CSS file? We do that by adding a  &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; element inside the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of our HTML page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;rel&lt;/code&gt; attribute specifies the relationship between the &lt;code&gt;index.html&lt;/code&gt; file and the linked document (&lt;code&gt;style.css&lt;/code&gt;) and we set it to &lt;code&gt;stylesheet&lt;/code&gt;. The &lt;code&gt;href&lt;/code&gt; attribute points to the location of the linked document.&lt;/p&gt;

&lt;p&gt;Check the result and we can see that the external CSS file styles have been applied.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pfkgIEQ0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/niyxu4cbq24k6fvyehc5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pfkgIEQ0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/niyxu4cbq24k6fvyehc5.jpg" alt="External CSS" width="553" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The good thing about the external CSS method is that if we add another page and we want the same styles to be applied to our &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt; tags, we only need to import the &lt;code&gt;style.css&lt;/code&gt; file in that page.&lt;/p&gt;

&lt;p&gt;Tailwind CSS uses an external CSS file that contains all the CSS classes we can apply to elements on our pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chrome Developer Tools (DevTools)
&lt;/h2&gt;

&lt;p&gt;Let's use &lt;strong&gt;Chrome Developer Tools (DevTools)&lt;/strong&gt; to inspect the styles applied to our page.  We can use Chrome DevTools to inspect the CSS applied to the elements on the page. &lt;code&gt;Right click&lt;/code&gt; on the page and select &lt;code&gt;Inspect&lt;/code&gt;. If it opens on the right side, click the "three dots icon" on the top right corner and change the "Dock side" to the bottom.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aEkeA92o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h3i1qxsf1z45onnvu54.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aEkeA92o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h3i1qxsf1z45onnvu54.jpg" alt="Chrome Developer Tool Dock Side" width="880" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under the "Elements" tab, click on any element and that will show the styles applied to the element on the right side under the styles tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IrH4bq9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qdlx3s7mbnp11cj5nam.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IrH4bq9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qdlx3s7mbnp11cj5nam.jpg" alt="Styles tab" width="880" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to debug your page or something is not working as expected, Chrome DevTools will help you to find the issue faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Selectors
&lt;/h2&gt;

&lt;p&gt;So far we only covered one type of selector and that is selecting an element based on the element's tag name but we can use other ways as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type Selector
&lt;/h3&gt;

&lt;p&gt;We have used type selectors in our examples. We write the element's tag name as the selector. This example will change all the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; elements' font size to &lt;code&gt;40 pixels&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Save the file and check the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4z-yOnwA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dt7gpv1t8zv343wdyzw8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4z-yOnwA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dt7gpv1t8zv343wdyzw8.jpg" alt="CSS Type Selector" width="880" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We notice from the Chrome DevTools that both the inline CSS and the external CSS styles have been applied to our &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag. We can also see the file name &lt;code&gt;style.css&lt;/code&gt; that the CSS is coming from. Chrome DevTools allows us to modify the styles applied and try different styles before we actually add them to our code.&lt;/p&gt;

&lt;p&gt;A type selector is useful if we want to apply the same style to all the elements of one type. But let's say we have two &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; elements and we want to set the font size of one of them to &lt;code&gt;40 pixels&lt;/code&gt; and the other one to &lt;code&gt;20 pixels&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add the following &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag under the one we have now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Never Stop Learning&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and check the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mi1bAz3R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a87alxul8tu3srprmbjg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mi1bAz3R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a87alxul8tu3srprmbjg.jpg" alt="CSS Type Selector Problem" width="431" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that the font size &lt;code&gt;40px&lt;/code&gt; got applied to both of the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tags but we only want that for the first &lt;code&gt;h1&lt;/code&gt; and for the second &lt;code&gt;h1&lt;/code&gt;  we want the font size to be &lt;code&gt;20px&lt;/code&gt;. We need another way to target a specific element and apply styles to it.&lt;/p&gt;

&lt;h3&gt;
  
  
  ID Selector
&lt;/h3&gt;

&lt;p&gt;We can set a unique &lt;code&gt;id&lt;/code&gt; attribute on an element and then apply CSS to it using the id selector. To make the browser know that this is an id selector and not a type selector, we prefix the id with a &lt;code&gt;#&lt;/code&gt; sign. So first, let's add two different ids to our &lt;code&gt;h1&lt;/code&gt; elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"mainHeading"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color:red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Code Pro Max&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"subHeading"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Never Stop Learning&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that each of the &lt;code&gt;h1&lt;/code&gt; elements has an id attribute, we can target the first one by setting the selector to &lt;code&gt;#mainHeading&lt;/code&gt; and the second by setting the selector to &lt;code&gt;#subHeading&lt;/code&gt;. I have removed the previous &lt;code&gt;h1&lt;/code&gt; selector since now we have an id selector for it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#mainHeading&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#subHeading&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;save the file and check the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T5TwNJor--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vz4j6fbdyp21zbe4nrn1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T5TwNJor--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vz4j6fbdyp21zbe4nrn1.jpg" alt="CSS ID Selector" width="370" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that each of the &lt;code&gt;h1&lt;/code&gt; elements got its own styles with the id selector.&lt;/p&gt;

&lt;p&gt;The id selector solves the problem with the type selectors but what if we have a page with 5 different types of &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tags and we want to show two of them in red, two of them in orange, and the other one in blue? If we want to use the id selector, we will repeat ourselves.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code&gt;index.html&lt;/code&gt; file, after the &lt;code&gt;h3&lt;/code&gt; element, add the following paragraphs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"paragraph-red-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"paragraph-red-2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Second paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"paragraph-orange-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Third paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"paragraph-orange-2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Forth paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"paragraph-blue"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fifth paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And for the CSS we will need to add the following to target each paragraph and set their color:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#paragraph-red-1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#paragraph-red-2&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#paragraph-orange-1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#paragraph-orange-2&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#paragraph-blue&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vzdMgU3e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c02jatib1a7aukpp2lb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vzdMgU3e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c02jatib1a7aukpp2lb.jpg" alt="CSS ID Selector Problem" width="211" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We got it working but we have the same &lt;code&gt;color: red;&lt;/code&gt; or &lt;code&gt;color: orange&lt;/code&gt; applied multiple times. If we have 20 more paragraphs to show in red, we have to create 20 more styles in our CSS file to target them. The reason for repeating the same styles is that we cannot have the same &lt;code&gt;id&lt;/code&gt; attribute for another element. The &lt;code&gt;id&lt;/code&gt; attribute's value must be unique on each page. This is where the class selector can be helpful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Class Selector
&lt;/h3&gt;

&lt;p&gt;We use the class selectors if we have multiple elements that are using the same styles. In the last example, we had multiple paragraphs that use the same color. In order to use the class selector, we first need to add a &lt;code&gt;class&lt;/code&gt; attribute to our element. I will first delete all the ids on the paragraphs and then add a class to them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Second paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-orange"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Third paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-orange"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Forth paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-blue"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fifth paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;class&lt;/code&gt; attribute's value can be the same on multiple elements. In our CSS, delete the previous styles and add the following styles with the class selector. In order to tell the browser that we are targeting an element's class, we need to prefix the class name with a dot "&lt;code&gt;.&lt;/code&gt;" in our CSS file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-red&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.text-orange&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.text-blue&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and check the result&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qpTuUgWO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jyphh40oocqy548hhns.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qpTuUgWO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jyphh40oocqy548hhns.jpg" alt="CSS Class Selector" width="244" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result is the same but now we have fewer lines of CSS and we can add the classes &lt;code&gt;text-red&lt;/code&gt;, &lt;code&gt;text-orange&lt;/code&gt;, or &lt;code&gt;text-blue&lt;/code&gt; to any other elements and change their text color. Another advantage of using class selectors is that we can add multiple classes to an element separated by a space and that will apply all of the styles to the element.&lt;/p&gt;

&lt;p&gt;Let's add the following classes at the end of the &lt;code&gt;style.css&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-small&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.text-medium&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.text-large&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the second class to any of the paragraphs separated by space to change the font size on them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red text-large"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-red text-medium"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Second paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-orange text-small"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Third paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-orange text-large"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Forth paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-blue text-small"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fifth paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that will apply both styles to our paragraphs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nztWiKUS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvu7kesg9w8krtniazir.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nztWiKUS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvu7kesg9w8krtniazir.jpg" alt="CSS Class Selector" width="485" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tailwind CSS works with classes and we apply those classes to our elements using the &lt;code&gt;class&lt;/code&gt; attribute.&lt;/p&gt;

&lt;p&gt;There are other selectors that we can use but these were the important ones and for Tailwind CSS, most of the time we are using classes. You can check &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors"&gt;this&lt;/a&gt; link or &lt;a href="https://www.w3schools.com/cssref/css_selectors.asp"&gt;this&lt;/a&gt; one for more information on CSS selectors.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Comments
&lt;/h2&gt;

&lt;p&gt;You can also add comments to your CSS. This is useful if you want to explain the CSS you have written. A comment will only be visible in your code and it will not display in the browser or affect a page's layout. A CSS comment starts with &lt;code&gt;/*&lt;/code&gt; and ends with &lt;code&gt;*/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* This text will not show in the browser or affect the layout of the page */&lt;/span&gt;

&lt;span class="c"&gt;/* We can have
multiline
comments
*/&lt;/span&gt;

&lt;span class="c"&gt;/*
CSS styles in the comments will not be applied
.text-very-large{
  font-size: 100px;
}
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Properties List
&lt;/h2&gt;

&lt;p&gt;In the examples we covered so far, we only had two basic CSS properties color and font-size but there are a lot of properties we can use. You can head over to &lt;a href="https://www.w3schools.com/cssref/"&gt;w3schools.com/cssref&lt;/a&gt; and check all of the CSS properties available with code examples. The reason I didn't cover those is that Tailwind CSS uses them in a different way. We use Tailwind CSS classes to apply styles to our elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next?
&lt;/h2&gt;

&lt;p&gt;Now that you know how CSS works, you can move to install Tailwind CSS and start learning about the CSS classes it provides.&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
