<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ CSS3 - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ CSS3 - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Wed, 06 May 2026 14:40:03 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/css3/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Build Simpler Accordion Menus with HTML <details> ]]>
                </title>
                <description>
                    <![CDATA[ Accordion menus are everywhere on the web because users want fast answers and smooth navigation. They help create clean, organized, and user-friendly interfaces. Many developers still reach for JavaScript to build accordions, which adds avoidable com... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-build-simpler-accordion-menus-with-html-details/</link>
                <guid isPermaLink="false">687e45310fc9d9c1bc2da5f7</guid>
                
                    <category>
                        <![CDATA[ HTML5 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ophy Boamah ]]>
                </dc:creator>
                <pubDate>Mon, 21 Jul 2025 13:48:33 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753119637759/0fb5302d-c21c-4c0d-affb-3f891261aabf.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Accordion menus are everywhere on the web because users want fast answers and smooth navigation.</p>
<p>They help create clean, organized, and user-friendly interfaces. Many developers still reach for JavaScript to build accordions, which adds avoidable complexities to their projects.</p>
<p>The HTML <code>&lt;details&gt;</code> element solves this problem with its built-in disclosure widget that toggles content visibility using just a few lines of HTML and optional CSS.</p>
<p>In this article, we’ll look at an FAQ accordion built using <code>&lt;details&gt;</code>. You can see the final project <a class="post-section-overview" href="#heading-our-example-project">here</a>.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-is-the-html-element">What is the HTML <code>&lt;details&gt;</code> Element?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-an-faq-accordion-built-with-the-element">An FAQ Accordion Built with the <code>&lt;details&gt;</code> Element</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-browser-support-and-accessibility-considerations">Browser Support and Accessibility Considerations</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-what-is-the-html-element">What is the HTML <code>&lt;details&gt;</code> Element?</h2>
<p>The HTML <code>&lt;details&gt;</code> element is a disclosure widget that allows you to hide and show content with a single click. Think of it as a native accordion that comes built into HTML.</p>
<p>The most common use case for accordions is the Frequently Asked Questions (FAQ) section on many sites. If you’ve seen or interacted with an FAQ, that’s an opportunity to use <code>&lt;details&gt;</code>.</p>
<p>It has two main components:</p>
<ul>
<li><p><code>&lt;details&gt;</code> is the main container tag that opens and closes to display what’s in <code>&lt;summary&gt;</code>.</p>
</li>
<li><p><code>&lt;summary&gt;</code> is a container for the content that is displayed when <code>&lt;details&gt;</code> is clicked.</p>
</li>
</ul>
<p>💡 In addition to the <code>summary</code>, you can include any HTML text element within the <code>&lt;details&gt;</code> container.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752662432707/0d6ebbae-d68d-400f-9209-a83feec273b7.png" alt="0d6ebbae-d68d-400f-9209-a83feec273b7" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The image above shows a real-life use case of <code>&lt;details&gt;</code> on the Apple website. In a later section, we’ll learn about the browsers that support it.</p>
<h3 id="heading-when-to-use-over-javascript-alternatives">When to Use <code>&lt;details&gt;</code> over JavaScript alternatives</h3>
<p>Unlike JavaScript-based accordions that add weight to your project, <code>&lt;details&gt;</code> offers the same functionality with minimal load and better performance. It also offers built-in keyboard navigation and screen reader support.</p>
<p>Choose <code>&lt;details&gt;</code> over JavaScript-created accordions when:</p>
<ul>
<li><p>Building simple accordions or FAQ sections</p>
</li>
<li><p>Accessibility, performance, and SEO are a priority</p>
</li>
<li><p>You want to avoid JavaScript dependencies</p>
</li>
</ul>
<h2 id="heading-an-faq-accordion-built-with-the-element">An FAQ Accordion Built with the <code>&lt;details&gt;</code> Element</h2>
<p>Here’s what our example project looks like:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752662715342/74db7ba5-f7a6-44be-974c-36c0418c4a81.png" alt="Example project using the  element" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>This design is by <a target="_blank" href="https://www.frontendmentor.io/?via=ophyboamah">Frontend Mentor</a> (and you can check out the project on <a target="_blank" href="https://codepen.io/ophyboamah/full/ByaRqaN">Codepen</a>).</p>
<p>To follow along, you need basic knowledge of HTML and CSS. Since the focus of this article is &lt;details&gt;, we won't place a lot of emphasis on the starting HTML and CSS code (available on the Codepen above). Instead, we'll look at one FAQ question with its answer to learn how &lt;details&gt; works.</p>
<h3 id="heading-how-to-use">How to Use <code>&lt;details&gt;</code></h3>
<p>To create an accordion with the <code>&lt;details&gt;</code> element, you need both the <code>&lt;details&gt;</code> and <code>&lt;summary&gt;</code> elements, as shown in the starter code below.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">details</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">summary</span>&gt;</span>What is Frontend Mentor, and how will it help me?<span class="hljs-tag">&lt;/<span class="hljs-name">summary</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Frontend Mentor offers realistic coding challenges to help developers improve their frontend coding skills with projects in HTML, CSS, and JavaScript. It’s suitable for all levels and ideal for portfolio building.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">details</span>&gt;</span>
</code></pre>
<p>The GIF below will be the result after running the above code. With less than five lines of HTML code, we already have an accordion.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752662956079/25c66453-71ba-469c-8dd2-0f1b8e3b9d7f.gif" alt="25c66453-71ba-469c-8dd2-0f1b8e3b9d7f" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h3 id="heading-styling">Styling <code>&lt;details&gt;</code></h3>
<p>Now, let's focus on transforming our basic accordion into something visually appealing (foundational styles can be found on the <a target="_blank" href="https://codepen.io/ophyboamah/full/ByaRqaN">Codepen</a>). First, we’ll add the icons as SVGs within <code>&lt;summary&gt;</code> with classes (closed-icon and open-icon) to make them easy to style.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">details</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">summary</span>&gt;</span>What is Frontend Mentor, and how will it help me?
  <span class="hljs-tag">&lt;<span class="hljs-name">svg</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"closed-icon"</span> <span class="hljs-attr">xmlns</span>=<span class="hljs-string">"&lt;http://www.w3.org/2000/svg&gt;"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"closed-icon"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"30"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"31"</span> <span class="hljs-attr">viewBox</span>=<span class="hljs-string">"0 0 30 31"</span> <span class="hljs-attr">fill</span>=<span class="hljs-string">"none"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">path</span> <span class="hljs-attr">d</span>=<span class="hljs-string">"M15 3.3125C12.5895 3.3125 10.2332 4.02728 8.22899 5.36646C6.22477 6.70564 4.66267 8.60907 3.74022 10.836C2.81778 13.063 2.57643 15.5135 3.04668 17.8777C3.51694 20.2418 4.67769 22.4134 6.38214 24.1179C8.08659 25.8223 10.2582 26.9831 12.6223 27.4533C14.9865 27.9236 17.437 27.6822 19.664 26.7598C21.8909 25.8373 23.7944 24.2752 25.1335 22.271C26.4727 20.2668 27.1875 17.9105 27.1875 15.5C27.1835 12.2689 25.8981 9.17131 23.6134 6.88659C21.3287 4.60186 18.2311 3.31653 15 3.3125ZM19.6875 16.4375H15.9375V20.1875C15.9375 20.4361 15.8387 20.6746 15.6629 20.8504C15.4871 21.0262 15.2486 21.125 15 21.125C14.7514 21.125 14.5129 21.0262 14.3371 20.8504C14.1613 20.6746 14.0625 20.4361 14.0625 20.1875V16.4375H10.3125C10.0639 16.4375 9.82541 16.3387 9.64959 16.1629C9.47378 15.9871 9.375 15.7486 9.375 15.5C9.375 15.2514 9.47378 15.0129 9.64959 14.8371C9.82541 14.6613 10.0639 14.5625 10.3125 14.5625H14.0625V10.8125C14.0625 10.5639 14.1613 10.3254 14.3371 10.1496C14.5129 9.97377 14.7514 9.875 15 9.875C15.2486 9.875 15.4871 9.97377 15.6629 10.1496C15.8387 10.3254 15.9375 10.5639 15.9375 10.8125V14.5625H19.6875C19.9361 14.5625 20.1746 14.6613 20.3504 14.8371C20.5262 15.0129 20.625 15.2514 20.625 15.5C20.625 15.7486 20.5262 15.9871 20.3504 16.1629C20.1746 16.3387 19.9361 16.4375 19.6875 16.4375Z"</span> <span class="hljs-attr">fill</span>=<span class="hljs-string">"#AD28EB"</span>/&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">svg</span>&gt;</span> 
  <span class="hljs-tag">&lt;<span class="hljs-name">svg</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"open-icon"</span> <span class="hljs-attr">xmlns</span>=<span class="hljs-string">"&lt;http://www.w3.org/2000/svg&gt;"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"open-icon"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"30"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"31"</span> <span class="hljs-attr">viewBox</span>=<span class="hljs-string">"0 0 30 31"</span> <span class="hljs-attr">fill</span>=<span class="hljs-string">"none"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">path</span> <span class="hljs-attr">d</span>=<span class="hljs-string">"M15 3.3125C12.5895 3.3125 10.2332 4.02728 8.22899 5.36646C6.22477 6.70564 4.66267 8.60907 3.74022 10.836C2.81778 13.063 2.57643 15.5135 3.04668 17.8777C3.51694 20.2418 4.67769 22.4134 6.38214 24.1179C8.08659 25.8223 10.2582 26.9831 12.6223 27.4533C14.9865 27.9236 17.437 27.6822 19.664 26.7598C21.8909 25.8373 23.7944 24.2752 25.1335 22.271C26.4727 20.2668 27.1875 17.9105 27.1875 15.5C27.1841 12.2687 25.899 9.17076 23.6141 6.8859C21.3292 4.60104 18.2313 3.31591 15 3.3125ZM19.6875 16.4375H10.3125C10.0639 16.4375 9.82541 16.3387 9.64959 16.1629C9.47378 15.9871 9.37501 15.7486 9.37501 15.5C9.37501 15.2514 9.47378 15.0129 9.64959 14.8371C9.82541 14.6613 10.0639 14.5625 10.3125 14.5625H19.6875C19.9361 14.5625 20.1746 14.6613 20.3504 14.8371C20.5262 15.0129 20.625 15.2514 20.625 15.5C20.625 15.7486 20.5262 15.9871 20.3504 16.1629C20.1746 16.3387 19.9361 16.4375 19.6875 16.4375Z"</span> <span class="hljs-attr">fill</span>=<span class="hljs-string">"#301534"</span>/&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">svg</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">summary</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Frontend Mentor offers realistic coding challenges to help developers improve their frontend coding skills with projects in HTML, CSS, and JavaScript. It’s suitable for all levels and ideal for portfolio building.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">details</span>&gt;</span>
</code></pre>
<p>In the code below, we customize the disclosure marker by hiding the default arrow and adding a custom icon to the right using the <code>::marker</code> pseudo-element on <code>&lt;summary&gt;</code>. We also set its content as empty, which removes the marker altogether.</p>
<pre><code class="lang-css"><span class="hljs-comment">/* Styles for the clickable summary element*/</span>
<span class="hljs-selector-tag">summary</span> {
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">700</span>;
  <span class="hljs-attribute">cursor</span>: pointer;
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">align-items</span>: center;
  <span class="hljs-attribute">transition</span>: color <span class="hljs-number">0.2s</span> ease;
  <span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">1em</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">1.5em</span>;
<span class="hljs-comment">/* Remove the default marker */</span>
  &amp;::marker {
    <span class="hljs-attribute">content</span>: <span class="hljs-string">''</span>;
  }

  &amp;<span class="hljs-selector-pseudo">:last-child</span> { 
    <span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">0</span>; 
  } 

  &amp;<span class="hljs-selector-pseudo">:hover</span> { 
    <span class="hljs-attribute">color</span>: <span class="hljs-built_in">var</span>(--text-accent);
    <span class="hljs-attribute">outline</span>: none;
  }
}

<span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">padding-top</span>: <span class="hljs-number">1em</span>;
  <span class="hljs-attribute">color</span>: <span class="hljs-built_in">var</span>(--text-light);
}
<span class="hljs-comment">/* Styles for the collapsible &lt;details&gt; container */</span>
<span class="hljs-selector-tag">details</span> {
  <span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">1em</span>;

  &amp;:last-child { 
    <span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">0</span>; 
  }

  <span class="hljs-selector-class">.open-icon</span> {
    <span class="hljs-attribute">display</span>: none;
  }

  &amp;<span class="hljs-selector-attr">[open]</span> {
    .open-icon {
      <span class="hljs-attribute">display</span>: inline;
    }

    <span class="hljs-selector-class">.closed-icon</span> {
      <span class="hljs-attribute">display</span>: none;
    }
  }

  <span class="hljs-selector-class">.open-icon</span>,
  <span class="hljs-selector-class">.closed-icon</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">1.8em</span>; 
    <span class="hljs-attribute">height</span>: <span class="hljs-number">1.8em</span>;
    <span class="hljs-attribute">flex-shrink</span>: <span class="hljs-number">0</span>;
  }
}
</code></pre>
<p>The GIF below shows the output of styling our accordion with the CSS code above.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752663406898/3d033ac2-e9d4-4836-8f3b-816513802353.gif" alt="3d033ac2-e9d4-4836-8f3b-816513802353" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>To have an FAQ question expanded when the page loads, add the <code>open</code> attribute to <code>&lt;details&gt;</code>. This is particularly useful for highlighting important information where the most crucial FAQ starts expanded.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">details</span> <span class="hljs-attr">open</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">summary</span>&gt;</span>What is Frontend Mentor, and how will it help me?<span class="hljs-tag">&lt;/<span class="hljs-name">summary</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">details</span>&gt;</span>
</code></pre>
<h2 id="heading-browser-support-and-accessibility-considerations">Browser Support and Accessibility Considerations</h2>
<p>According to <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details">MDN</a>, <code>&lt;details&gt;</code> is a well established feature that works across many devices and the popular browsers (Chrome, Edge, Firefox, and Safari) since January 2020.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752663542331/33407311-a4db-47ab-bc9f-16baaed5d060.png" alt="33407311-a4db-47ab-bc9f-16baaed5d060" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><code>&lt;details&gt;</code> includes built-in accessibility features that requires additional JavaScript in custom solutions such as keyboard navigation, screen reader support, and semantic structure. You can also add attributes like role, aria-expanded, and aria-labelledby to ensure even more accessibility.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p><code>&lt;details&gt;</code> is a powerful yet under-utilized element for creating UI elements like accordions, FAQs, or navigation menus without JavaScript. It is easy to implement and lightweight, and yet improves user experience with interactive content.</p>
<p>So, the next time you need to create any collapsible content, with accessibility and performance in mind, consider reaching for <code>&lt;details&gt;</code> and it will surely make your development life easier.</p>
<p>Here are some helpful resources:</p>
<ul>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details">MDN Documentation for <code>&lt;details&gt;</code></a></p>
</li>
<li><p><a target="_blank" href="https://css-tricks.com/quick-reminder-that-details-summary-is-the-easiest-way-ever-to-make-an-accordion/">CSS-Tricks Guide to Styling Details</a></p>
</li>
<li><p><a target="_blank" href="https://web.dev/learn/html/details/">Web.dev Learn HTML: Details</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Add Tailwind CSS to Your React Native Expo App ]]>
                </title>
                <description>
                    <![CDATA[ Tailwind CSS has been quite popular in the web development world due to its utility-first approach and seamless integration.  However, when developing mobile apps with React Native, integrating Tailwind CSS may be challenging. But guess what? Not any... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/tailwindcss-in-react-native-expo/</link>
                <guid isPermaLink="false">66b9ee776a5986e4892f960b</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React Native ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tailwind ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ John Caleb ]]>
                </dc:creator>
                <pubDate>Tue, 27 Feb 2024 09:22:11 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/02/FREECODE-CAMP-DEFAULT-1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Tailwind CSS has been quite popular in the web development world due to its utility-first approach and seamless integration. </p>
<p>However, when developing mobile apps with React Native, integrating Tailwind CSS may be challenging. But guess what? Not anymore. With the development of tools such as <a target="_blank" href="https://www.nativewind.dev/">NativeWind</a>, React Native developers can leverage Tailwind CSS power to design stunning and responsive mobile UIs easily.</p>
<p>In this tutorial, you'll learn the process of integrating Tailwind CSS to your React Native <a target="_blank" href="https://expo.io/">Expo</a> app using NativeWind. We'll also build a simple login screen with NativeWind.</p>
<h2 id="heading-table-of-contents">Table of Contents:</h2>
<ul>
<li><a class="post-section-overview" href="#heading-whats-nativewind">What's NativeWind?</a></li>
<li><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></li>
<li><a class="post-section-overview" href="#heading-getting-started">Getting Started</a> </li>
<li><a class="post-section-overview" href="#heading-how-to-create-a-new-expo-app">How to Create A New Expo App</a></li>
<li><a class="post-section-overview" href="#heading-how-to-install-nativewind">How to Install NativeWind</a></li>
<li><a class="post-section-overview" href="#heading-how-to-set-up-tailwind-css">How to Set Up Tailwind CSS</a></li>
<li><a class="post-section-overview" href="#heading-how-to-configure-nativewind-with-babel">How to Configure NativeWind With Babel</a></li>
<li><a class="post-section-overview" href="#heading-how-to-style-with-nativewind">How to Style with NativeWind</a></li>
<li><a class="post-section-overview" href="#heading-how-to-build-a-simple-login-screen">How to Build A Simple Login Screen</a></li>
<li><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></li>
</ul>
<h2 id="heading-whats-nativewind">What's NativeWind?</h2>
<p>NativeWind acts as a bridge between Tailwind CSS and React Native Expo, allowing developers to take advantage of Tailwind's utility-first approach in their mobile app development workflow. </p>
<p>NativeWind provides various benefits to developers, some of these benefits include:</p>
<ul>
<li><strong>Familiar Syntax</strong>: Developers that are familiar with Tailwind CSS can easily migrate to using NativeWind in their React Native projects, easing the learning curve.</li>
<li><strong>Consistent Styling:</strong> NativeWind ensures consistent styling across platforms by offering a single collection of components and services.</li>
<li><strong>Flexibility</strong>: NativeWind allows developers to easily adapt and extend styles to meet the app's design specifications.</li>
</ul>
<p>Overall, It provides a collection of components and tools that are very similar to Tailwind CSS, allowing developers to create shorter, more concise code while preserving flexibility and consistency across platforms.</p>
<blockquote>
<p>Tailwind makes writing code feel like I’m using a design tool - Didier Catz</p>
</blockquote>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li>Basic Understanding of React Native Expo and Tailwind CSS.</li>
<li>Node.js and npm (or yarn) installed.</li>
<li>Willingness to learn :)</li>
</ul>
<h2 id="heading-getting-started">Getting Started</h2>
<p>Before you dive into integrating Tailwind CSS into your React Native Expo app, you'll need to ensure that you have the necessary tools set up.</p>
<p>If you haven't already installed Expo and <a target="_blank" href="https://www.npmjs.com/package/expo-cli">expo-cli</a> globally, you can do so using npm or yarn:</p>
<pre><code class="lang-bash">npm install -g expo-cli
</code></pre>
<p>or </p>
<pre><code class="lang-bash">yarn global add expo-cli
</code></pre>
<h2 id="heading-how-to-create-a-new-expo-app">How to Create A New Expo App</h2>
<p>With expo-cli installed, you can now create a new React Native Expo project. </p>
<p>Navigate to the directory where you wish to create your project and open the terminal. You can do this by pressing <em>CTRL + `</em> on Visual Studio Code. Then execute this command in the terminal:</p>
<pre><code class="lang-bash">npx create-expo-app simpleproject
</code></pre>
<p>This command creates an expo project in your directory.</p>
<h2 id="heading-how-to-install-nativewind">How to Install NativeWind</h2>
<p>After creating your expo project, you can install NativeWind and its dependencies by running the following commands in your project's directory:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> simpleproject
npm i nativewind
npm i --dev tailwindcss@3.3.2
</code></pre>
<p>or</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> simpleproject
yarn add nativewind
yarn add --dev tailwindcss@3.3.2
</code></pre>
<p>Next, you'll need to create a <code>tailwind.config.js</code> file. To do this, run this command in your terminal:</p>
<pre><code class="lang-bash">npx tailwindcss init
</code></pre>
<p>This would result in a <code>tailwind.config.js</code> file in your project's root directory. </p>
<h2 id="heading-how-to-set-up-tailwind-css">How to Set Up Tailwind CSS</h2>
<p>To set up Tailwind CSS in your project, navigate to your <code>tailwind.config.js</code> file, and under <code>content</code>, enter the paths to your components. Your <code>tailwind.config.js</code> file would then look like this:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">/** <span class="hljs-doctag">@type <span class="hljs-type">{import('tailwindcss').Config}</span> </span>*/</span>
<span class="hljs-built_in">module</span>.exports = {
  <span class="hljs-attr">content</span>: [
    <span class="hljs-string">"./App.{js,jsx,ts,tsx}"</span>,
    <span class="hljs-string">"./&lt;custom directory&gt;/**/*.{js,jsx,ts,tsx}"</span>,
  ],
  <span class="hljs-attr">theme</span>: {
    <span class="hljs-attr">extend</span>: {},
  },
  <span class="hljs-attr">plugins</span>: [],
};
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/code-1.png" alt="A screenshot of tailwind.conf.js file after adding path to components" width="600" height="400" loading="lazy">
<em>tailwind.conf.js file after adding paths to components</em></p>
<p>In the above example, you can replace <code>&lt;custom directory&gt;</code> with your directory's real name.</p>
<h2 id="heading-how-to-configure-nativewind-with-babel">How to Configure NativeWind with Babel</h2>
<p>You'll also need to configure NativeWind with Babel. To do this, include the NativeWind plugin in your project's <code>babel.conf.js</code> file:</p>
<pre><code class="lang-javascript">plugins: [<span class="hljs-string">"nativewind/babel"</span>],
</code></pre>
<p>The <code>babel.conf.js</code> file would look like this after adding the NativeWind plugin:</p>
<pre><code class="lang-js"><span class="hljs-built_in">module</span>.exports = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">api</span>) </span>{
  api.cache(<span class="hljs-literal">true</span>);
  <span class="hljs-keyword">return</span> {
    <span class="hljs-attr">presets</span>: [<span class="hljs-string">"babel-preset-expo"</span>],
    <span class="hljs-attr">plugins</span>: [<span class="hljs-string">"nativewind/babel"</span>],
  };
};
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/code2-2.png" alt="babel.conf.js file after adding nativewind plugin" width="600" height="400" loading="lazy">
<em>babel.conf.js file after adding nativewind plugin</em></p>
<p>By including the NativeWind plugin in the Babel configuration file you ensure that NativeWind's functionality is properly incorporated into your project's JavaScript codebase.</p>
<p> 🎉With this, NativeWind has been successfully integrated into your Expo app. The next step is to begin styling the app with NativeWind.</p>
<h2 id="heading-how-to-style-with-nativewind">How to Style with NativeWind</h2>
<p>To begin styling with NativeWind, go to your project's <code>App.js</code> file or the component you would like to style, which would look like this by default:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { StatusBar } <span class="hljs-keyword">from</span> <span class="hljs-string">"expo-status-bar"</span>;
<span class="hljs-keyword">import</span> { StyleSheet, Text, View } <span class="hljs-keyword">from</span> <span class="hljs-string">"react-native"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{styles.container}</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Text</span>&gt;</span>Open up App.js to start working on your app!<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">StatusBar</span> <span class="hljs-attr">style</span>=<span class="hljs-string">'auto'</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">const</span> styles = StyleSheet.create({
  <span class="hljs-attr">container</span>: {
    <span class="hljs-attr">flex</span>: <span class="hljs-number">1</span>,
    <span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">"#fff"</span>,
    <span class="hljs-attr">alignItems</span>: <span class="hljs-string">"center"</span>,
    <span class="hljs-attr">justifyContent</span>: <span class="hljs-string">"center"</span>,
  },
});
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/appjs-default.png" alt="App.js boilerplate code" width="600" height="400" loading="lazy">
<em>App.js boilerplate code</em></p>
<p>Next, modify your component to get rid of any instances of <code>StyleSheet</code> abstraction. In this example, we'll modify the <code>App.js</code> code. After adjustments, we should have something like this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { StatusBar } <span class="hljs-keyword">from</span> <span class="hljs-string">"expo-status-bar"</span>;
<span class="hljs-comment">// import { StyleSheet, Text, View } from "react-native";</span>
<span class="hljs-keyword">import</span> { Text, View } <span class="hljs-keyword">from</span> <span class="hljs-string">"react-native"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="hljs-comment">// &lt;View style={styles.container}&gt;</span>
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'flex-1 justify-center items-center bg-white'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Text</span>&gt;</span>Open up App.js to start working on your app!<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">StatusBar</span> <span class="hljs-attr">style</span>=<span class="hljs-string">'auto'</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span></span>
  );
}

<span class="hljs-comment">// const styles = StyleSheet.create({</span>
<span class="hljs-comment">//   container: {</span>
<span class="hljs-comment">//     flex: 1,</span>
<span class="hljs-comment">//     backgroundColor: "#fff",</span>
<span class="hljs-comment">//     alignItems: "center",</span>
<span class="hljs-comment">//     justifyContent: "center",</span>
<span class="hljs-comment">//   },</span>
<span class="hljs-comment">// });</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/newww.png" alt="App.js component after modification " width="600" height="400" loading="lazy">
<em>App.js component after modification</em></p>
<p>In the modified codeblock, we remove all occurrences of <code>StyleSheet</code> abstractions, including the import statement for <code>stylesheet</code> and the <code>StyleSheet.create</code> function, and we replace <code>style</code> with <code>className</code> in the <code>App.js</code> return function.</p>
<p>Having cleared that up, all you need to do is write Tailwind CSS classes into your app <code>className</code> to begin implementing Tailwind CSS in your application. You'll see this in a bit as we build a simple login screen with NativeWind.</p>
<h2 id="heading-how-to-build-a-simple-login-screen">How to Build A Simple Login Screen</h2>
<p>Now, let's dive into building a simple login screen using NativeWind. We'll continue with the initial setup in the <code>App.js</code> file and gradually add components to create the login UI.</p>
<p>First, let's replace the existing code in the <code>App.js</code> file with the following:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { StatusBar } <span class="hljs-keyword">from</span> <span class="hljs-string">"expo-status-bar"</span>;
<span class="hljs-keyword">import</span> { Text, View } <span class="hljs-keyword">from</span> <span class="hljs-string">"react-native"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'flex-1 justify-center items-center bg-white'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">StatusBar</span> <span class="hljs-attr">style</span>=<span class="hljs-string">'auto'</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-center mt-3 text-2xl font-light text-orange-300'</span>&gt;</span>
        Login
      <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
      {/* Additional components goes here */}
    <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span></span>
 );
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/firstt.png" alt="Starter code for login screen UI" width="600" height="400" loading="lazy">
<em>Starter code for login screen UI</em></p>
<p>The code above imports the essential components from React Native and Expo. We then use a <code>View</code> component to define the structure of our login screen, which is styled with NativeWind's utility classes. Inside the <code>View</code>, we have a <code>Text</code> component that displays "Login" with styling applied using NativeWind classes.</p>
<p>Next, you can add your login form components, such as username and password input fields, a login button, and any other necessary elements. Here is an example of how you can extend the login screen:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { StatusBar } <span class="hljs-keyword">from</span> <span class="hljs-string">"expo-status-bar"</span>;
<span class="hljs-keyword">import</span> { Text, View, TouchableOpacity, TextInput } <span class="hljs-keyword">from</span> <span class="hljs-string">"react-native"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'flex-1 justify-center items-center bg-white'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">StatusBar</span> <span class="hljs-attr">style</span>=<span class="hljs-string">'auto'</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-center mt-3 text-2xl font-light text-orange-300'</span>&gt;</span>
        Login
      <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
      {/* Additional components goes here */}
      <span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'mt-5 mx-5'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">View</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-gray-400'</span>&gt;</span>EMAIL:<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">TextInput</span>
            <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Enter Email...'</span>
            <span class="hljs-attr">className</span>=<span class="hljs-string">'border border-dotted p-2 text-gray-500 border-amber-400 mt-1'</span>
          /&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'mt-3'</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-gray-400'</span>&gt;</span>PASSWORD:<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">TextInput</span>
            <span class="hljs-attr">secureTextEntry</span>
            <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Enter Password...'</span>
            <span class="hljs-attr">className</span>=<span class="hljs-string">'border text-gray-500 border-dotted p-2 border-amber-400 mt-1'</span>
          /&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">TouchableOpacity</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'bg-orange-300 p-3 mt-4'</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-center text-base text-white'</span>&gt;</span>Login<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">TouchableOpacity</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-center font-normal text-gray-500 text-base mt-3'</span>&gt;</span>
          OR
        <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'mt-4'</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">TouchableOpacity</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'flex flex-row items-center justify-center p-2 bg-orange-300'</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-white mx-2 text-sm'</span>&gt;</span>Sign In With Google<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">TouchableOpacity</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">View</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'mt-6 flex-row justify-center'</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">''</span>&gt;</span>New to FreeCodeCamp? <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">TouchableOpacity</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'text-amber-500'</span>&gt;</span>Create an Account<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">TouchableOpacity</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">View</span>&gt;</span></span>
  );
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/nextend-1.png" alt="Extended login screen UI with additional components " width="600" height="400" loading="lazy">
<em>Extended login screen UI with additional components</em></p>
<p>In this expanded version, we've included <code>TextInput</code> components for the username and password input fields, as well as a <code>TouchableOpacity</code> for the login button. Styling is done with NativeWind's utility classes to provide a clean and consistent appearance.</p>
<p>Furthermore, once you've finished creating your login screen using NativeWind in your React Native Expo project, you'll want to test it to check if everything works properly. You can do this by running this command on your terminal:</p>
<pre><code class="lang-bash">expo start
</code></pre>
<p>This command will launch the bundler and generate a QR code. To open the app, scan the QR code displayed in the terminal with your emulator's camera, or press "a" for Android or "i" for iOS.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/02/Screenshot_20240223-015329.png" alt="Output of the code in an emulator" width="600" height="400" loading="lazy">
<em>Output of the code in an emulator</em></p>
<p>If you need to, you can access <a target="_blank" href="https://github.com/thejohncaleb/simpleproject">the complete project code</a> on GitHub.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Integrating Tailwind CSS into a React Native Expo project with NativeWind has various benefits, including increased developer efficiency, code consistency, and performance. Developers can easily create amazing mobile applications by leveraging the power of Tailwind CSS's utility-first approach and React Native's native features.</p>
<p>NativeWind makes it easy to apply Tailwind CSS to your React Native Expo app. Using Tailwind CSS in your mobile app development workflow opens up new possibilities for UI design and customization.</p>
<p>Remember, if you have any questions or just want to say hi, feel free to reach me on <a target="_blank" href="https://twitter.com/thejohncaleb">X(Twitter)</a> or my <a target="_blank" href="https://thejohncaleb.netlify.app/contact">website</a>. :)</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Tailwind CSS and How Can I Add it to my Website or React App? ]]>
                </title>
                <description>
                    <![CDATA[ CSS is a technology that can be your best or worst friend. While it's incredibly flexible and can produce what seems like magic, without the proper care and attention, it can become hard to manage like any other code.  How can Tailwind CSS help us to... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-tailwind-css-and-how-can-i-add-it-to-my-website-or-react-app/</link>
                <guid isPermaLink="false">66b8e39e0196ee8e3efce546</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS Framework ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Developer Tools ]]>
                    </category>
                
                    <category>
                        <![CDATA[ framework ]]>
                    </category>
                
                    <category>
                        <![CDATA[ front end ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Front-end Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ frontend ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML ]]>
                    </category>
                
                    <category>
                        <![CDATA[ PostCSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tailwind ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tools ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Colby Fayock ]]>
                </dc:creator>
                <pubDate>Tue, 19 May 2020 14:45:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/tailwind-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>CSS is a technology that can be your best or worst friend. While it's incredibly flexible and can produce what seems like magic, without the proper care and attention, it can become hard to manage like any other code. </p>
<p>How can Tailwind CSS help us to take control of our styles?</p>
<ul>
<li><a class="post-section-overview" href="#heading-what-is-tailwind">What is Tailwind?</a></li>
<li><a class="post-section-overview" href="#heading-so-what-makes-tailwind-great">So what makes Tailwind great?</a></li>
<li><a class="post-section-overview" href="#heading-part-1-adding-tailwind-css-to-a-static-html-page">Part 1: Adding Tailwind CSS to a static HTML page</a></li>
<li><a class="post-section-overview" href="#heading-part-2-adding-tailwind-css-to-a-react-app">Part 2: Adding Tailwind CSS to a React app</a></li>
</ul>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/7KeZcRMltP0" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-what-is-tailwind">What is Tailwind?</h2>
<p><a target="_blank" href="https://tailwindcss.com/">Tailwind CSS</a> is a "utility-first" CSS framework that provides a deep catalog of CSS classes and tools that lets you easily get started styling your website or application.</p>
<p>The underlying goal is that as you're building your project, you don't need to deal with cascading styles and worrying about how to override that 10-selector pileup that's been haunting your app for the last 2 years.</p>
<h2 id="heading-so-what-makes-tailwind-great">So what makes Tailwind great?</h2>
<p>Taildwind's solution is to provide a wide variety of CSS classes that each have their own focused use. Instead of a class called <code>.btn</code> that is created with a bunch of CSS attributes directly, in Tailwind, you would either apply a bunch of classes like <code>bg-blue-500 py-2 px-4 rounded</code> to the button element or build a <code>.btn</code> class by <a target="_blank" href="https://tailwindcss.com/docs/functions-and-directives/#apply">applying</a> those utility class to that selector.</p>
<p>While Tailwind has a lot more going for it, we're going to focus on these basics for this tutorial, so let's dig in!</p>
<h2 id="heading-part-1-adding-tailwind-css-to-a-static-html-page">Part 1: Adding Tailwind CSS to a static HTML page</h2>
<p>We're going to start off by applying Tailwind CSS straight to a static HTML page. The hope is that by focusing on Tailwind and not the app, we can get a better understanding of what's actually happening with the framework.</p>
<h3 id="heading-step-1-creating-a-new-page">Step 1: Creating a new page</h3>
<p>You can get started by simply creating a new HTML file. For the content, you can use whatever you want, but I'm going to use <a target="_blank" href="http://fillerama.io/">fillerama.io</a> so the filler content is a bit more fun.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-with-content.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>New HTML page with content</em></p>
<p>If you want to simplify this step, you can just <a target="_blank" href="https://github.com/colbyfayock/my-tailwind-static/commit/c7db11899c9cd193cdd666fd228cfaefe75623f2#diff-eacf331f0ffc35d4b482f1d15a887d3b">copy the file I created</a> to get started.</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-static/commit/c7db11899c9cd193cdd666fd228cfaefe75623f2">Follow along with the commit!</a></p>
<h3 id="heading-step-2-adding-tailwind-css-via-cdn">Step 2: Adding Tailwind CSS via CDN</h3>
<p>Tailwind typically recommends that you install through <a target="_blank" href="https://www.npmjs.com/package/tailwindcss">npm</a> to get the full functionality, but again, we're just trying to understand how this works first.</p>
<p>So let's add a link to the CDN file in the <code>&lt;head&gt;</code> of our document:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span>&gt;</span>
</code></pre>
<p>Once you save and reload the page, the first thing you'll notice is that all of the styles were stripped!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-tailwind-base.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with the Tailwind CSS base</em></p>
<p>This is expected. Tailwind includes a set of <a target="_blank" href="https://tailwindcss.com/docs/preflight">preflight styles</a> to fix cross-browser inconsistencies. For one, they include the popular <a target="_blank" href="https://github.com/necolas/normalize.css/">normalize.css</a> which they build upon with their own styles.</p>
<p>But we're going to learn how to use Tailwind to add back our styles and set things up how we want!</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-static/commit/b431b75cee0a03154a70b194b6dfcf028bc65942">Follow along with the commit!</a></p>
<h3 id="heading-step-3-using-tailwind-css-to-add-styles-to-your-page">Step 3: Using Tailwind CSS to add styles to your page</h3>
<p>Now that we have Tailwind installed, we've added the ability to make use of their huge library of utility classes that we'll now use to add styles back to our page.</p>
<p>Let's start off by adding some margin to all of our paragraphs (<code>&lt;p&gt;</code>) and our list elements (<code>&lt;ol&gt;</code>, <code>&lt;ul&gt;</code>). We can do this by adding the <code>.my-5</code> class to each element like so:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"my-5"</span>&gt;</span>
  Bender, quit destroying the universe! Yeah, I do that with my stupidness. I never loved you. Moving along…
  Belligerent and numerous.
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>The class name follows a pattern that you'll notice with the rest of the utility classes – <code>.my-5</code> stands for margin (m) applied to the y-axis (y) with a value of 5 which in Tailwind's case, it uses <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units">rem</a>, so the value is 5rem.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-paragraph-styles.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with basic paragraph styles</em></p>
<p>Next, let's make our headers look like actual headers. Starting with our <code>h1</code> tag, let's add:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"text-2xl font-bold mt-8 mb-5"</span>&gt;</span>
</code></pre>
<p>Here's what's happening:</p>
<ul>
<li><code>text-2xl</code>: set the text size (font-size) to 2xl. In Tailwind, that 2xl will equate to 1.5rem</li>
<li><code>font-bold</code>: set the weight of the text (font-weight) to bold</li>
<li><code>mt-8</code>: Similar to <code>my-5</code>, this will set the margin top (t) to 8rem</li>
<li><code>mb-5</code>: And this will set the margin bottom (b) to 5rem</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-header-styles.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with styled H1</em></p>
<p>With those classes added to the <code>h1</code>, let's apply those same exact classes to the rest of our header elements, but as we go down the list, reduce the size of the font size, so it will look like:</p>
<ul>
<li>h2: <code>text-xl</code></li>
<li>h3: <code>text-lg</code></li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-all-headers-style.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with all headers styled</em></p>
<p>Now let's make our list elements look like lists. Starting with our unordered list (<code>&lt;ul&gt;</code>), let's add these classes:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"list-disc list-inside my-5 pl-2"</span>&gt;</span>
</code></pre>
<p>Here's what we're adding:</p>
<ul>
<li><code>list-disc</code>: set the list-style-stype to disc (the markers on each line item)</li>
<li><code>list-inside</code>: sets the position of the list markers using  relative to the list items and the list itself with list-style-position to inside</li>
<li><code>my-5</code>: set the margin of the y axis to 5rem</li>
<li><code>pl-2</code>: set the left padding to 2rem</li>
</ul>
<p>Then we can apply the exact same classes to our ordered list (<code>&lt;ol&gt;</code>), except instead of <code>list-disc</code>, we want to change our style type to <code>list-decimal</code>, so that we can see numbers given it's an ordered list.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">ol</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"list-decimal list-inside my-5 pl-2"</span>&gt;</span>
</code></pre>
<p>And we have our lists!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-styled-lists.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with styled lists</em></p>
<p>Finally, let's make our content a little easier to read by setting a max width and centering the content. On the <code>&lt;body&gt;</code> tag, add the following:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">body</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"max-w-4xl mx-auto"</span>&gt;</span>
</code></pre>
<p>/Note: Typically you wouldn't want to apply these classes to the <code>&lt;body&gt;</code> itself, rather, you can wrap all of your content with a <code>&lt;main&gt;</code> tag, but since we're just trying to get an idea of how this works, we'll roll with this. Feel free to add the <code>&lt;main&gt;</code> tag with those classes instead if you prefer!/</p>
<p>And with that, we have our page!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-content-centered.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with centered content</em></p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-static/commit/06fd719c98d17e2242b61ec2ab7034436c1c2ba6">Follow along with the commit!</a></p>
<h3 id="heading-step-4-adding-a-button-and-other-components">Step 4: Adding a button and other components</h3>
<p>For the last part of our static example, let's add a button.</p>
<p>The trick with Tailwind, is they intentionally don't provide pre-baked component classes with the idea being that likely people would need to override these components anyways to make them look how they wanted.</p>
<p>So that means, we're going to have to create our own using the utility classes!</p>
<p>First, let's add a new button. Somewhere on the page, add the following snippet. I'm going to add it right below the first paragraph (<code>&lt;p&gt;</code>) tag:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Party with Slurm!<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-unstyled-button.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with unstyled button</em></p>
<p>You'll notice just like all of the other elements, that it's unstyled, however, if you try clicking it, you'll notice it still has the click actions. So let's make it look like a button.</p>
<p>Let's add the following classes:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"text-white font-bold bg-purple-700 hover:bg-purple-800 py-2 px-4 rounded"</span>&gt;</span>
  Party with Slurm!
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>Here's a breakdown of what's happening:</p>
<ul>
<li><code>text-white</code>: we're setting our text color to white</li>
<li><code>font-bold</code>: set the weight of the text to bold (font-weight)</li>
<li><code>bg-purple-700</code>: set the background color of the button to purple with a shade of 700. The 700 is relative to the other colors defined as purple, you can find these values on their <a target="_blank" href="https://tailwindcss.com/docs/customizing-colors#default-color-palette">palette documentation page</a></li>
<li><code>hover:bg-purple-800</code>: when someone hovers over the button, set the background color to purple shade 800. Tailwind provides these helper classes that allow us to easily define interactive stiles with things like <a target="_blank" href="https://tailwindcss.com/course/hover-focus-and-active-styles/">hover, focus, and active modifiers</a></li>
<li><code>py-2</code>: set the padding of the y-axis to 2rem</li>
<li><code>px-4</code>: set the padding of the  x-axis to 4rem</li>
<li><code>rounded</code>: round the corners of the element by setting the border radius. With tailwind, it sets the border-radius value to .25rem</li>
</ul>
<p>And with all of that, we have our button!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-page-styled-button.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>HTML page with a styled button</em></p>
<p>You can apply this methodology to any other component that you'd like to build. Though it's a manual process, we'll find out how we can make this process easier when building in more dynamic projects like those based on React.</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-static/commit/09312336dce316a75e8007d6c935133490f16c25">Follow along with the commit!</a></p>
<h2 id="heading-part-2-adding-tailwind-css-to-a-react-app">Part 2: Adding Tailwind CSS to a React app</h2>
<p>For more of a real-world use case, we're going to add Tailwind CSS to an app created with <a target="_blank" href="https://reactjs.org/docs/create-a-new-react-app.html">Create React App</a>.</p>
<p>First, we'll walk through the steps you need to take to add tailwind to your project using a fresh install of Create React App, then we'll use our content from our last example to recreate it in React.</p>
<h3 id="heading-step-1-spinning-up-a-new-react-app">Step 1: Spinning up a new React app</h3>
<p>I'm not going to detail this step out too much. The gist is we'll bootstrap a new React app using Create React App.</p>
<p>To get started, you can follow along <a target="_blank" href="https://reactjs.org/docs/create-a-new-react-app.html">with the directions</a> from the official React documentation:</p>
<p><a target="_blank" href="https://reactjs.org/docs/create-a-new-react-app.html">https://reactjs.org/docs/create-a-new-react-app.html</a></p>
<p>And once you start your development server, you should now see an app!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/create-react-app-starting-page.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Create React App starting page</em></p>
<p>Finally, let's migrate all of our old content to our app. To do this, copy everything inside of the <code>&lt;body&gt;</code> tag of our static example and paste it inside of the wrapper <code>&lt;div className="App"&gt;</code> in the new React project.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/code-migrating-content.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Migrating code to React app</em></p>
<p>Next, change all <code>class="</code> attributes from the content we pasted in to <code>className="</code> so that it's using proper React attributes:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/code-fixing-class-attribute.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Fixing class attribute in content</em></p>
<p>And lastly, replace the className <code>App</code> on our wrapper <code>&lt;div&gt;</code> to the classes we used on our static <code>&lt;body&gt;</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/code-wrapper-styles.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Adding wrapper styles to the app</em></p>
<p>Once you save your changes and spin back up your server, it will look deceivingly okay.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/react-app-basic-content.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>React app with basic content</em></p>
<p>React includes some basic styles itself, so while it looks okay, we're not actually using Tailwind yet. So let's get started by installing it!</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-dynamic/commit/57993883c77739f71072bcc02ed2398543efc2fd">Follow along with the commit!</a></p>
<h3 id="heading-step-2-installing-tailwind-in-your-react-app">Step 2: Installing Tailwind in your React app</h3>
<p>There are a few steps we'll need to go through in order to get Tailwind up and running on our app. Make sure you follow these steps carefully to ensure it's properly configured.</p>
<p>First, let's add our dependencies:</p>
<pre><code>yarn add tailwindcss postcss-cli autoprefixer
# or
npm install tailwindcss postcss-cli autoprefixer
</code></pre><p><a target="_blank" href="https://tailwindcss.com/docs/installation#4-process-your-css-with-tailwind">Per Tailwind's documentation</a>, we need to be able to process our styles so that they can be properly added to our pipeline. So in the above, we're adding:</p>
<ul>
<li><a target="_blank" href="https://tailwindcss.com/">tailwindcss</a>: the core Tailwind package</li>
<li><a target="_blank" href="https://github.com/postcss/postcss">postcss-cli</a>: Create React App already uses postcss, but we need to configure Tailwind to be part of that build process and run it's own processing</li>
<li><a target="_blank" href="https://github.com/postcss/autoprefixer">autoprefixer</a>: Tailwind doesn't include vendor prefixes, so we want to add autoprefixer to handle this for us. This runs as part of our postcss configuration</li>
</ul>
<p>We're also going to add two dev dependencies that make it easier to work with our code:</p>
<pre><code>yarn add concurrently chokidar-cli -D
# or
npm install concurrently chokidar-cli --save-dev
</code></pre><ul>
<li><a target="_blank" href="https://github.com/kimmobrunfeldt/concurrently">concurrently</a>: a package that lets us set up the ability to run multiple commands at once. This is helpful since we'll need to watch both the styles and React app itself.</li>
<li><a target="_blank" href="https://github.com/kimmobrunfeldt/chokidar-cli">chokidar-cli</a>: let's us watch files and run a command when changed. We'll use this to watch our CSS file and run the build process of the CSS on cahnge</li>
</ul>
<p>Next, let's configure postcss, so create a new file in the root of your project called <code>postcss.config.js</code> and include the following:</p>
<pre><code class="lang-js"><span class="hljs-comment">// Inside postcss.config.js</span>
<span class="hljs-built_in">module</span>.exports = {
    <span class="hljs-attr">plugins</span>: [
        <span class="hljs-built_in">require</span>(<span class="hljs-string">'tailwindcss'</span>),
        <span class="hljs-built_in">require</span>(<span class="hljs-string">'autoprefixer'</span>)
    ],
};
</code></pre>
<p>This will add the Tailwindcss and Autoprefixer plugins to our postcss config.</p>
<p>With our configuration, we need to include it as part of the build and watch processes. Inside <code>package.json</code>, add the following to definitions to your <code>scripts</code> property:</p>
<pre><code class="lang-json"><span class="hljs-string">"build:css"</span>: <span class="hljs-string">"tailwind build src/App.css -o src/index.css"</span>,
<span class="hljs-string">"watch:css"</span>: <span class="hljs-string">"chokidar 'src/App.css' -c 'npm run build:css'"</span>,
</code></pre>
<p>Additionally, modify the <code>start</code> and <code>build</code> scripts to now include those commands:</p>
<pre><code class="lang-json"><span class="hljs-string">"start"</span>: <span class="hljs-string">"concurrently -n Tailwind,React 'npm run watch:css' 'react-scripts start'"</span>,
<span class="hljs-string">"build"</span>: <span class="hljs-string">"npm run build:css &amp;&amp; react-scripts build"</span>,
</code></pre>
<p>With our configuration ready to go, let's try our styles back to where they were when we left off from the static example.</p>
<p>Inside the <code>App.css</code> file, replace the entire content with:</p>
<pre><code class="lang-css"><span class="hljs-keyword">@tailwind</span> base;
<span class="hljs-keyword">@tailwind</span> components;
<span class="hljs-keyword">@tailwind</span> utilities;
</code></pre>
<p>This is going to import Tailwind's base styles, components, and utility classes that allow Tailwind to work as you would expect it to.</p>
<p>We can also remove the <code>App.css</code> import from our <code>App.js</code> file because it's now getting injected directly into our <code>index.css</code> file. So remove this line:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> <span class="hljs-string">'./App.css'</span>;
</code></pre>
<p>Once you're done, you can start back up your development server! If it was already started, make sure to restart it so all of the configuration changes take effect.</p>
<p>And now the page should look exactly like it did in our static example!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/react-app-with-styled-content.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>React app with content styled</em></p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-dynamic/commit/5f50cc218ef58f469dad7f09bdad31f36b58a896">Follow along with the commit!</a></p>
<h3 id="heading-step-3-creating-a-new-button-component-class-with-tailwind">Step 3: Creating a new button component class with Tailwind</h3>
<p>Tailwind doesn't ship with prebaked component classes, but it does make it easy to create them!</p>
<p>We're going to use our button that we already created as an example of creating a new component. We'll create a new class <code>btn</code> as well as a color modifier <code>btn-purple</code> to accomplish this.</p>
<p>The first thing we'll want to do is open up our App.css file where we'll create our new class. Inside that file, let's add:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.btn</span> {
  @apply font-bold py-2 px-4 rounded;
}
</code></pre>
<p>If you remember from our HTML, we're already including those same classes to our <code>&lt;button&gt;</code> element.  Tailwind let's us "apply" or include the styles that make up these utility classes to another class, in this case, the <code>.btn</code> class.</p>
<p>And now that we're creating that class, let's apply it to our button:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"btn text-white bg-purple-700 hover:bg-purple-800"</span>&gt;</span>
  Party with Slurm!
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>And if we open up our page, we can see our button still looks the same. If we inspect the element, we can see our new <code>.btn</code> class generated with those styles.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/react-tailwind-button-class.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>.btn class in a React app with Tailwind</em></p>
<p>Next, let's create a color modifier. Similar to what we just did, we're going to add the following rules:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.btn-purple</span> {
  @apply bg-purple-700 text-white;
}

<span class="hljs-selector-class">.btn-purple</span><span class="hljs-selector-pseudo">:hover</span> {
  @apply bg-purple-800;
}
</code></pre>
<p>Here, we're adding our background color and our text color to our button class. We're also applying a darker button color when someone hovers over the button.</p>
<p>We'll also want to update our HTML button to include our new class and remove the ones we just applied:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"btn btn-purple"</span>&gt;</span>
  Party with Slurm!
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>And with that change, we can still see that nothing has changed and we have our new button class!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/react-tailwind-styled-button.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Styled button in React with Tailwind</em></p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-tailwind-dynamic/commit/7a76e8a4583b0a4c523ea902d73e889c7b86f437">Follow along with the commit!</a></p>
<h2 id="heading-applying-these-concepts-to-more-components">Applying these concepts to more components</h2>
<p>Through this walkthrough, we learned how to create a new component class using the Tailwind apply directive. This allowed us to create reusable classes that represent a component like a button.</p>
<p>We can apply this to any number of components in our design system. For instance, if we wanted to always show our lists the way we set them up here, we could create a <code>.list-ul</code> class that represented an unordered list with the Tailwind utilities <code>list-disc list-inside my-5 pl-2</code> applied.</p>
<h2 id="heading-what-tips-and-tricks-do-you-like-to-use-with-tailwind">What tips and tricks do you like to use with Tailwind?</h2>
<p>Share with me on <a target="_blank" href="https://twitter.com/colbyfayock">Twitter</a>!</p>
<div id="colbyfayock-author-card">
  <p>
    <a href="https://twitter.com/colbyfayock">
      <img src="https://res.cloudinary.com/fay/image/upload/w_2000,h_400,c_fill,q_auto,f_auto/w_1020,c_fit,co_rgb:007079,g_north_west,x_635,y_70,l_text:Source%20Sans%20Pro_64_line_spacing_-10_bold:Colby%20Fayock/w_1020,c_fit,co_rgb:383f43,g_west,x_635,y_6,l_text:Source%20Sans%20Pro_44_line_spacing_0_normal:Follow%20me%20for%20more%20JavaScript%252c%20UX%252c%20and%20other%20interesting%20things!/w_1020,c_fit,co_rgb:007079,g_south_west,x_635,y_70,l_text:Source%20Sans%20Pro_40_line_spacing_-10_semibold:colbyfayock.com/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_68,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_145,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_222,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_295,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/v1/social-footer-card" alt="Follow me for more Javascript, UX, and other interesting things!" width="2000" height="400" loading="lazy">
    </a>
  </p>
  <ul>
    <li>
      <a href="https://twitter.com/colbyfayock">? Follow Me On Twitter</a>
    </li>
    <li>
      <a href="https://youtube.com/colbyfayock">?️ Subscribe To My Youtube</a>
    </li>
    <li>
      <a href="https://www.colbyfayock.com/newsletter/">✉️ Sign Up For My Newsletter</a>
    </li>
  </ul>
</div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Box Shadow CSS Tutorial – How to Add a Drop Shadow to Any HTML Element ]]>
                </title>
                <description>
                    <![CDATA[ By Joe Liang We can add a drop shadow to any HTML element using the CSS property box-shadow. Here's how. ##Adding a Basic Drop Shadow Let's first set up some basic HTML elements to add our drop shadows to: ```html Box1 Box2 Box3 Then add some basic ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/css-tutorial-drop-shadow/</link>
                <guid isPermaLink="false">66d45f65706b9fb1c166b989</guid>
                
                    <category>
                        <![CDATA[ #box-shadow ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ css properties ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Pure CSS ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 18 May 2020 13:00:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/feature.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Joe Liang</p>
<p>We can add a drop shadow to any HTML element using the CSS property <code>box-shadow</code>. Here's how.</p>
<p>##Adding a Basic Drop Shadow</p>
<p>Let's first set up some basic HTML elements to add our drop shadows to:</p>
<p>```html</p>
<div id="box1" class="box">Box1</div>
<div id="box2" class="box">Box2</div>
<div id="box3" class="box">Box3</div>

<p>Then add some basic CSS:</p>
<p>```css
p {
    padding: 10px;
}
.box {
    padding: 20px;
    width: 50%;
    margin: 30px auto;
    background: #000;
    color: #fff;
}</p>
<p>The result is just three black boxes that will be easy for us to add drop shadows to by calling their unique id's:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-elements-1.png" alt="HTML elements setup" width="600" height="400" loading="lazy">
<em>HTML elements setup</em></p>
<p>To add a basic drop shadow, let's use the <code>box-shadow</code> property on the Box 1:</p>
<p>```css
/<em> offset-x | offset-y | color </em>/</p>
<p>#box1 {
    box-shadow: 6px 12px yellow;
}</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/box1.png" alt="Adding a basic drop shadow to Box 1" width="600" height="400" loading="lazy">
<em>Adding a basic drop shadow to Box 1</em></p>
<p>We have 3 parameters here. The first 2 are, respectively, the x-offset and y-offset. They set the location of the drop shadow.</p>
<p>The offset is relative to the origin, which in HTML is always the top left corner of an element. A positive x-offset will move the shadow to the right, and a positive y-offset will move the shadow downwards.</p>
<p>The third parameter is the color of your drop shadow.</p>
<p>Keep in mind that although we used <code>&lt;div&gt;</code> elements here, the <code>box-shadow</code> property can be applied to any other HTML element as well.</p>
<p>##Adding a Blur Radius</p>
<p>If we want the shadow to look a little more realistic, we will want to experiment with the <code>blur-radius</code> parameter.</p>
<p>This parameter controls how much to blur the shadow such that it becomes bigger and lighter. Let's apply it to Box 2:</p>
<p>```css
/<em> offset-x | offset-y | blur-radius | color </em>/</p>
<p>#box2 {
    box-shadow: 6px 12px 4px red;
}</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/box2-blur.png" alt="Adding a blur radius to Box 2" width="600" height="400" loading="lazy">
<em>Adding a blur radius to Box 2</em></p>
<p>The value of 4px sets the radius of the blur to apply to our drop shadow.</p>
<p>##Adding a Spread Radius</p>
<p>If we want to control the size of the shadow, we can use the <code>spread-radius</code> parameter which controls how much a shadow grows or shrinks.</p>
<p>Let's add a spread radius of 8px to Box 2:</p>
<p>```css
/<em> offset-x | offset-y | blur-radius | spread-radius | color </em>/</p>
<p>#box2 {
    box-shadow: 6px 12px 4px 8px red;
}</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/box2-blur-and-spread.png" alt="Adding a spread radius in addition to a blur to Box 2" width="600" height="400" loading="lazy">
<em>Adding a spread radius in addition to a blur to Box 2</em></p>
<p>Remember the order of these parameters!</p>
<p>##Combining Multiple Shadows in a Single Property</p>
<p>If we want to get fancy, we can add multiple drop shadows to an element using a single <code>box-shadow</code> property.</p>
<p>Let's do that with Box 3 by simultaneously adding a blue and green drop shadow:</p>
<p>```css
/<em> Any number of shadows, separated by commas </em>/</p>
<p>#box3 {
    box-shadow: 6px 12px 2px 2px blue, -6px -12px 2px 2px green;
}</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/box3.png" alt="combine multiple drop shadows" width="600" height="400" loading="lazy">
<em>Adding multiple drop shadows to Box 3</em></p>
<p>##Bonus: Create an Inset Shadow</p>
<p>While it will not create a drop shadow, the <code>inset</code> parameter can also be used with the <code>box-shadow</code> property.</p>
<p>As the name suggests, this parameter creates an inset shadow (i.e. shadow inside a box).</p>
<p>The <code>inset</code> parameter can be placed either at the beginning or the end of the 
<code>box-shadow</code> property. Here we demonstrate its use with a <code>blockquote</code> element.</p>
<p>HTML:</p>
<p>```html</p>
<blockquote>
  <q>The key to success is to start before you're ready.</q>
  <p>— Marie Forleo</p>
</blockquote>

<p>CSS:</p>
<p>```css
blockquote {
  width: 50%;
  margin: 50px auto;
  padding: 20px;
  font-size: 24px;
  box-shadow: inset 10px 5px black;
}</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/blockquote.png" alt="Create an inset shadow" width="600" height="400" loading="lazy">
<em>Create an inset shadow</em></p>
<p>Of course you can add some blur and spread to enhance the shadow, or even multiple shadows:</p>
<p>```css
 box-shadow: inset 10px 5px 25px 5px black, 5px 5px 12px 2px black;</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/blockquote-enhanced.png" alt="Inset shadow combined with drop shadow" width="600" height="400" loading="lazy">
<em>Inset shadow combined with drop shadow</em></p>
<p>With the <code>box-shadow</code> property, we can easily make elements on a web page stand out to create a nice 3D lighting effect.</p>
<p>If you want to do some experimenting yourself, here's a <a target="_blank" href="https://codepen.io/1000mileworld/pen/dyYeggy">code pen</a> I created with the examples used in this tutorial.</p>
<p>Play around and see what you can come up with!</p>
<p>##Want to See More Web Development Tips and Knowledge?</p>
<ul>
<li><a target="_blank" href="https://1000mileworld.com/#post">Subscribe</a> to my weekly newsletter</li>
<li>Visit my blog at  <a target="_blank" href="https://1000mileworld.com/">1000 Mile World</a></li>
<li><a target="_blank" href="https://twitter.com/1000mileworld">Follow me</a> on Twitter</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Pure CSS to Create a Beautiful Loading Animation for your App ]]>
                </title>
                <description>
                    <![CDATA[ If you've been around the internet lately, you've most likely seen a nice subtle loading animation that fills page content before gracefully loading in.  Some of the social giants like Facebook even use this approach to give page loading a better exp... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-css-to-create-a-beautiful-loading-animation-for-your-app/</link>
                <guid isPermaLink="false">66b8e3730cedc1f2a4f7069f</guid>
                
                    <category>
                        <![CDATA[ animation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ animations ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ front end ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Front-end Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ frontend ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML5 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Inspiration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Pure CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Applications ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Colby Fayock ]]>
                </dc:creator>
                <pubDate>Tue, 05 May 2020 14:45:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/loading-animation.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you've been around the internet lately, you've most likely seen a nice subtle loading animation that fills page content before gracefully loading in. </p>
<p>Some of the social giants like Facebook even use this approach to give page loading a better experience. How can we do that with just some simple CSS?</p>
<ul>
<li><a class="post-section-overview" href="#heading-what-are-we-going-to-build">What are we going to build?</a></li>
<li><a class="post-section-overview" href="#heading-just-want-the-snippet">Just want the snippet?</a></li>
<li><a class="post-section-overview" href="#heading-part-1-creating-our-loading-animation">Part 1: Creating our loading animation</a></li>
<li><a class="post-section-overview" href="#heading-part-2-using-our-loading-animation-in-a-dynamic-app">Part 2: Using our loading animation in a dynamic app</a></li>
</ul>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/auyZWWjXJCo" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-what-are-we-going-to-build">What are we going to build?</h2>
<p>We're going to create a loading animation using a CSS class that you can apply to pretty much any element you want (within reason).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/loading-animation.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Loading animation preview</em></p>
<p>This gives you great flexibility to use it and makes the solution nice and simple with only CSS.</p>
<p>While the snippet is pretty small and you could just copy and paste it, I'll walk you through what's happening and an example of using it dynamically when loading data.</p>
<h2 id="heading-just-want-the-snippet">Just want the snippet?</h2>
<p>You can grab it here!</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="d155418975d1e0e04b2805e285296033">
        <script src="https://gist.github.com/colbyfayock/d155418975d1e0e04b2805e285296033.js"></script></div><h2 id="heading-do-i-need-to-know-how-to-animate-before-this-tutorial">Do I need to know how to animate before this tutorial?</h2>
<p>No! We'll walk through in detail exactly what you need to do. In fact, the animation in this tutorial is relatively simple, so let's dig in!</p>
<h2 id="heading-part-1-creating-our-loading-animation">Part 1: Creating our loading animation</h2>
<p>This first part is going to focus on getting the loading animation together and seeing it on a static HTML website. The goal is to walk through actually creating the snippet. We'll only use HTML and CSS for this part.</p>
<h3 id="heading-step-1-creating-some-sample-content">Step 1: Creating some sample content</h3>
<p>To get started, we'll want a little sample content. There's really no restrictions here, you can create this with basic HTML and CSS or you can add this to your Create React App!</p>
<p>For the walk through, I'm going to use HTML and CSS with a few examples of content that will allow us to see this in effect.</p>
<p>To get started, create a new HTML file. Inside that HTML file, fill it with some content that will give us the ability to play with our animation. I'm going to use <a target="_blank" href="http://fillerama.io/">fillerama</a> which uses lines from my favorite TV show <a target="_blank" href="https://en.wikipedia.org/wiki/Futurama">Futurama</a>!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-website-fillerama.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Static HTML &amp; CSS webpage with content from fillerama.io</em></p>
<p>If you're going to follow along with me, here's what my project looks like:</p>
<pre><code>my-css-loading-animation-<span class="hljs-keyword">static</span>
- index.html
- main.css
</code></pre><p><a target="_blank" href="https://github.com/colbyfayock/my-css-loading-animation-static/commit/9aa7925f7048fa1b73fef74d0d56380c29fc5d73">Follow along with the commit!</a></p>
<h3 id="heading-step-2-starting-with-a-foundation-loading-class">Step 2: Starting with a foundation loading class</h3>
<p>For our foundation, let's create a new CSS class. Inside our CSS file, let's add:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.loading</span> {
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#eceff1</span>;
}
</code></pre>
<p>With that class, let's add it to a few or all of our elements. I added it to a few paragraphs, headings, and lists.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"loading"</span>&gt;</span>For example...
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-gray-background.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Static HTML &amp; CSS webpage with a gray background for the content</em></p>
<p>That gives us a basic background, but we'd probably want to hide that text. When it's loading, we won't have that text yet, so most likely we would want to use filler text or a fixed height. Either way, we can set the color to transparent:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.loading</span> {
  <span class="hljs-attribute">color</span>: transparent;
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#eceff1</span>;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-gray-background-hidden-text.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Static HTML &amp; CSS webpage with a gray background and transparent color for the content</em></p>
<p>If you notice with list elements, whether you apply the class to the top level list element (<code>&lt;ol&gt;</code> or <code>&lt;ul&gt;</code>) vs the list item itself (<code>&lt;li&gt;</code>), it looks like one big block. If we add a little margin to the bottom of all list elements, we can see a different in how they display:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">li</span> {
  <span class="hljs-attribute">margin-bottom</span>: .<span class="hljs-number">5em</span>;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-gray-background-different-lists.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Style difference between applying to the top level list or the list items</em></p>
<p>And now it's starting to come together, but it kind of just looks like placeholders. So let's animate this to look like it's actually loading.</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-css-loading-animation-static/commit/f68cdef36be11311a5cc11a1d39e52ea7e7bb48d">Follow along with the commit!</a></p>
<h3 id="heading-step-3-styling-and-animating-our-loading-class">Step 3: Styling and animating our loading class</h3>
<p>Before actually animating our class, we need something to animate, so let's add a gradient to our <code>.loading</code> class:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.loading</span> {
  <span class="hljs-attribute">color</span>: transparent;
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">100deg</span>, #eceff1 <span class="hljs-number">30%</span>, #f6f7f8 <span class="hljs-number">50%</span>, #eceff1 <span class="hljs-number">70%</span>);
}
</code></pre>
<p>This is saying that we want a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient">linear gradient</a> that's tilted at 100 degrees, where we start with <code>#eceff1</code> and fade to <code>#f6f7f8</code> at 30% and back to <code>#eceff1</code> at 70%;</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-gray-background-subtle-gradient.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Subtle gradient background that might look like a glare</em></p>
<p>It's hard to see initially when it's still, it might just look like a glare on your computer! If you'd like to see it before moving on, feel free to play with the colors above to see the gradient.</p>
<p>Now that we have something to animate, we'll first need to create a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes">keyframes</a> rule:</p>
<pre><code class="lang-css"><span class="hljs-keyword">@keyframes</span> loading {
  0% {
    <span class="hljs-attribute">background-position</span>: <span class="hljs-number">100%</span> <span class="hljs-number">50%</span>;
  }
  100% {
    <span class="hljs-attribute">background-position</span>: <span class="hljs-number">0</span> <span class="hljs-number">50%</span>;
  }
}
</code></pre>
<p>This rule when applied will change the background position from starting at 100% of the x-axis to 0% of the x-axis.</p>
<p>With the rule, we can add our <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations">animation</a> property to our <code>.loading</code> class:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.loading</span> {
  <span class="hljs-attribute">color</span>: transparent;
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">100deg</span>, #eceff1 <span class="hljs-number">30%</span>, #f6f7f8 <span class="hljs-number">50%</span>, #eceff1 <span class="hljs-number">70%</span>);
  <span class="hljs-attribute">animation</span>: loading <span class="hljs-number">1.2s</span> ease-in-out infinite;
}
</code></pre>
<p>Our animation line is setting the keyframe to <code>loading</code>, telling it to last for 1.2 seconds, setting the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function">timing function</a> to <code>ease-in-out</code> to make it smooth, and tell it to loop forever with <code>infinite</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-gray-background-subtle-gradient.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>No change – it's not animating</em></p>
<p>If you notice though after saving that, it's still not doing anything. The reason for this is we're setting our gradient from one end of the DOM element to the other, so there's nowhere to move!</p>
<p>So let's try also setting a <code>background-size</code> on our <code>.loading</code> class.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.loading</span> {
  <span class="hljs-attribute">color</span>: transparent;
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">100deg</span>, #eceff1 <span class="hljs-number">30%</span>, #f6f7f8 <span class="hljs-number">50%</span>, #eceff1 <span class="hljs-number">70%</span>);
  <span class="hljs-attribute">background-size</span>: <span class="hljs-number">400%</span>;
  <span class="hljs-attribute">animation</span>: loading <span class="hljs-number">1.2s</span> ease-in-out infinite;
}
</code></pre>
<p>Now, since our background expands beyond our DOM element (you can't see that part), it has some space to animate with and we get our animation!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/static-html-css-loading-animation.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Our loading animation!</em></p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-css-loading-animation-static/commit/bc4b5ec955a0906fea032edbbaf90f037f76c91b">Follow along with the commit!</a></p>
<h2 id="heading-part-2-using-our-loading-animation-in-a-dynamic-app">Part 2: Using our loading animation in a dynamic app</h2>
<p>Now that we have our loading animation, let's put it into action with a basic example where we fake a loading state.</p>
<p>The trick with actually using this is typically we don't have the actual content available, so in most cases, we have to fake it.</p>
<p>To show you how we can do this, we're going to build a simple <a target="_blank" href="https://reactjs.org/">React</a> app with <a target="_blank" href="https://nextjs.org/">Next.js</a>.</p>
<h3 id="heading-step-1-creating-an-example-react-app-with-nextjs">Step 1: Creating an example React app with Next.js</h3>
<p>Navigate to the directory you want to create your new project in and run:</p>
<pre><code class="lang-shell">yarn create next-app
# or
npm init next-app
</code></pre>
<p>It will prompt you with some options, particularly a name which will determine the directory the project is created in and the type of project. I'm using <code>my-css-loading-animation-dynamic</code> and the "Default Starter App".</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/nextjs-new-project.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Creating a new project with Next.js</em></p>
<p>Once installed, navigate into your new directory and start up your development server:</p>
<pre><code>cd [directory]
yarn dev
# or 
npm run dev
</code></pre><p><img src="https://www.freecodecamp.org/news/content/images/2020/05/nextjs-starting-dev-server.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Starting development server with Next.js</em></p>
<p>Next, let's replace the content in our <code>pages/index.js</code> file. I'm going to derive the content from the previous example, but we'll create it similar to how we might expect it to come from an API. First, let's add our  content as an object above our return statement:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> content = {
  <span class="hljs-attr">header</span>: <span class="hljs-string">`So, how 'bout them Knicks?`</span>,
  <span class="hljs-attr">intro</span>: <span class="hljs-string">`What are their names? I'm Santa Claus! This opera's as lousy as it is brilliant! Your lyrics lack subtlety. You can't just have your characters announce how they feel. That makes me feel angry! Good news, everyone! I've taught the toaster to feel love!`</span>,
  <span class="hljs-attr">list</span>: [
    <span class="hljs-string">`Yes! In your face, Gandhi!`</span>,
    <span class="hljs-string">`So I really am important? How I feel when I'm drunk is correct?`</span>,
    <span class="hljs-string">`Who are those horrible orange men?`</span>
  ]
}
</code></pre>
<p>To display that content, inside <code>&lt;main&gt;</code>, let's replace the content with:</p>
<pre><code class="lang-jsx">&lt;main&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>{ content.header }<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>{ content.intro }<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    { content.list.map((item, i) =&gt; {
      return (
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{i}</span>&gt;</span>{ item }<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      )
    })}
  <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span></span>
&lt;/main&gt;
</code></pre>
<p>And for the styles, you can copy and paste everything from our Part 1 <code>main.css</code> file into the <code>&lt;style&gt;</code> tags at the bottom of our index page. That will leave us with:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/basic-content-with-nextjs.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Basic content with Next.js</em></p>
<p>With that, we should be back to a similar point we finished at in Part 1 except we're not actively using any of the loading animations yet.</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-css-loading-animation-dynamic/commit/365e081522ec07b1754bf360a95b0bc373476c95">Follow along with the commit!</a></p>
<h3 id="heading-step-2-faking-loading-data-from-an-api">Step 2: Faking loading data from an API</h3>
<p>The example we're working with is pretty simple. You'd probably see this coming pre-generated statically, but this helps us create a realistic demo that we can test our loading animation with.</p>
<p>To fake our loading state, we're going to use React's <code>useState</code>, <code>useEffect</code>, and an old fashioned <code>setTimeout</code> to preload some "loading" content, and after the <code>setTimeout</code> finishes, update that content with our actual data. In the meantime, we'll know that we're in a loading state with a separate instance of <code>useState</code>.</p>
<p>First, we need to import our dependencies. At the top of our <code>pages/index.js</code> file, add:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> { useState, useEffect } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
</code></pre>
<p>Above our <code>content</code> object, let's add some state:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">const</span> [loadingState, updateLoadingState] = useState(<span class="hljs-literal">true</span>);
<span class="hljs-keyword">const</span> [contentState, updateContentState] = useState({})
</code></pre>
<p>And in our content, we can update the instances to use that state:</p>
<pre><code class="lang-jsx">&lt;h1&gt;{ contentState.header }&lt;/h1&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>{ contentState.intro }<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  { contentState.list.map((item, i) =&gt; {
    return (
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{i}</span>&gt;</span>{ item }<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    )
  })}
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span></span>
</code></pre>
<p>Once you save and load that, you'll first notice we get an error because our <code>list</code> property doesn't exist on our <code>contentState</code>, so we can first fix that:</p>
<pre><code class="lang-jsx">{ <span class="hljs-built_in">Array</span>.isArray(contentState.list) &amp;&amp; contentState.list.map(<span class="hljs-function">(<span class="hljs-params">item, i</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{i}</span>&gt;</span>{ item }<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span></span>
  )
})}
</code></pre>
<p>And after that's ready, let's add our <code>setTimeout</code> inside of a <code>useEffect</code> hook to simulate our data loading. Add this under our <code>content</code> object:</p>
<pre><code class="lang-jsx">useEffect(<span class="hljs-function">() =&gt;</span> {
  <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
    updateContentState(content);
    updateLoadingState(<span class="hljs-literal">false</span>)
  }, <span class="hljs-number">2000</span>);
}, [])
</code></pre>
<p>Once you save and open up your browser, you'll notice that for 2 seconds you don't have any content and then it loads in, basically simulating loading that data asynchronously.</p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-css-loading-animation-dynamic/commit/f0cada8d696ffe3e983f5efc03dc9d75a2245fe1">Follow along with the commit!</a></p>
<h3 id="heading-step-3-adding-our-loading-animation">Step 3: Adding our loading animation</h3>
<p>Now we can finally add our loading animation. So to do this, we're going to use our loading state we set up using <code>useState</code> and if the content is loading, add our <code>.loading</code>  class to our elements.</p>
<p>Before we do that, instead of individually adding this class to each item in the DOM, it might make more sense to do so using CSS and adding the class to the parent, so let's do that first.</p>
<p>First, update the <code>.loading</code> class to target our elements:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.loading</span> <span class="hljs-selector-tag">h1</span>,
<span class="hljs-selector-class">.loading</span> <span class="hljs-selector-tag">p</span>,
<span class="hljs-selector-class">.loading</span> <span class="hljs-selector-tag">li</span> {
  <span class="hljs-attribute">color</span>: transparent;
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">100deg</span>, #eceff1 <span class="hljs-number">30%</span>, #f6f7f8 <span class="hljs-number">50%</span>, #eceff1 <span class="hljs-number">70%</span>);
  <span class="hljs-attribute">background-size</span>: <span class="hljs-number">400%</span>;
  <span class="hljs-attribute">animation</span>: loading <span class="hljs-number">1.2s</span> ease-in-out infinite;
}
</code></pre>
<p>Then we can dynamically add our class to our <code>&lt;main&gt;</code> tag:</p>
<pre><code class="lang-jsx">&lt;main className={loadingState ? <span class="hljs-string">'loading'</span> : <span class="hljs-string">''</span>}&gt;
</code></pre>
<p><em>Note: if you use <a target="_blank" href="https://sass-lang.com/">Sass</a>,  you can manage your loading styles by <a target="_blank" href="https://sass-lang.com/documentation/at-rules/extend">extending</a> the <code>.loading</code> class in the instances you want to use it or create a <a target="_blank" href="https://sass-lang.com/documentation/style-rules/placeholder-selectors">placeholder</a> and extend that!</em></p>
<p>And if you refresh the page, you'll notice it's still just a blank page for 2 seconds!</p>
<p>The issue, is when we load our content, nothing exists inside of our tags that can that would allow the line-height of the elements to give it a height.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-css-collapsed-content.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>No height when there's no content</em></p>
<p>But we can fix that! Because our <code>.loading</code> class sets our text to transparent, we can simply add the word <code>Loading</code> for each piece of content:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">const</span> [contentState, updateContentState] = useState({
  <span class="hljs-attr">header</span>: <span class="hljs-string">'Loading'</span>,
  <span class="hljs-attr">intro</span>: <span class="hljs-string">'Loading'</span>,
  <span class="hljs-attr">list</span>: [
    <span class="hljs-string">'Loading'</span>,
    <span class="hljs-string">'Loading'</span>,
    <span class="hljs-string">'Loading'</span>
  ]
})
</code></pre>
<p><em>Note: We can't use an empty space here because that alone won't provide us with a height when rendered in the DOM.</em></p>
<p>And once you save and reload the page, our first 2 seconds will have a loading state that reflects our content!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/html-css-loading-animation-1.gif" alt="Image" width="600" height="400" loading="lazy">
<em>HTML &amp; CSS loading animation</em></p>
<p><a target="_blank" href="https://github.com/colbyfayock/my-css-loading-animation-dynamic/commit/5b7b1c40d1eebf97f65c966bb771a5f6787073ea">Follow along with the commit!</a></p>
<h2 id="heading-some-additional-thoughts">Some additional thoughts</h2>
<p>This technique can be used pretty broadly. Being a CSS class makes it nice and easy to add where every you want.</p>
<p>If you're not a fan of setting the <code>Loading</code> text for the loading state, another option is to set a fixed height. The only issue with that is it requires more maintenance for tweaking the CSS to match what the content loading in will look like.</p>
<p>Additionally, this won't be perfect. More often than not, you won't know exactly how much copy you have on a page. The goal is to simulate and hint that there will be content and that it's currently loading.</p>
<h2 id="heading-whats-your-favorite-loading-animation">What's your favorite loading animation?</h2>
<p>Let me know on <a target="_blank" href="https://twitter.com/colbyfayock">Twitter</a>!</p>
<h2 id="heading-join-in-on-the-conversation">Join in on the conversation!</h2>
<div class="embed-wrapper">
        <blockquote class="twitter-tweet">
          <a href="https://twitter.com/freeCodeCamp/status/1264557769547493376"></a>
        </blockquote>
        <script defer="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div>
<div id="colbyfayock-author-card">
  <p>
    <a href="https://twitter.com/colbyfayock">
      <img src="https://res.cloudinary.com/fay/image/upload/w_2000,h_400,c_fill,q_auto,f_auto/w_1020,c_fit,co_rgb:007079,g_north_west,x_635,y_70,l_text:Source%20Sans%20Pro_64_line_spacing_-10_bold:Colby%20Fayock/w_1020,c_fit,co_rgb:383f43,g_west,x_635,y_6,l_text:Source%20Sans%20Pro_44_line_spacing_0_normal:Follow%20me%20for%20more%20JavaScript%252c%20UX%252c%20and%20other%20interesting%20things!/w_1020,c_fit,co_rgb:007079,g_south_west,x_635,y_70,l_text:Source%20Sans%20Pro_40_line_spacing_-10_semibold:colbyfayock.com/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_68,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_145,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_222,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_295,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/v1/social-footer-card" alt="Follow me for more Javascript, UX, and other interesting things!" width="2000" height="400" loading="lazy">
    </a>
  </p>
  <ul>
    <li>
      <a href="https://twitter.com/colbyfayock">? Follow Me On Twitter</a>
    </li>
    <li>
      <a href="https://youtube.com/colbyfayock">?️ Subscribe To My Youtube</a>
    </li>
    <li>
      <a href="https://www.colbyfayock.com/newsletter/">✉️ Sign Up For My Newsletter</a>
    </li>
  </ul>
</div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use the CSS3 Border Radius Property ]]>
                </title>
                <description>
                    <![CDATA[ With CSS3, you can give any element “rounded corners” by using the border-radius property. The value can be in any valid CSS length unit.   .rounded-corners {     border-radius: 20px;   }   .circle {     border-radius: 50%;   } ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-the-css3-border-radius-property/</link>
                <guid isPermaLink="false">66c355e239357f944697658a</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ toothbrush ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 04 Feb 2020 00:42:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/joel-fulgencio-VSrHD079L78-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>With CSS3, you can give any element “rounded corners” by using the <code>border-radius</code> property. The value can be in any valid CSS length unit.</p>
<pre><code class="lang-css">  <span class="hljs-selector-class">.rounded-corners</span> {
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">20px</span>;
  }

  <span class="hljs-selector-class">.circle</span> {
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">50%</span>;
  }
</code></pre>
<p><img src="https://github.com/kaithrendyle/guide-photos/blob/master/rounded-circle.png?raw=true" alt="examples" width="600" height="400" loading="lazy"></p>
<p><strong>Note:</strong> The <code>border-radius</code> property is actually a shorthand property for the <code>border-top-left-radius</code>, <code>border-top-right-radius</code>, <code>border-bottom-right-radius</code> and <code>border-bottom-left-radius</code> properties.</p>
<p>If just one value provided, the border-radius will be the same for all four corners, as in the examples above. But you also have the option to specify different values for each corner.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.new-shape</span> {
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">20px</span> <span class="hljs-number">50px</span> <span class="hljs-number">5px</span> <span class="hljs-number">0</span>; <span class="hljs-comment">/* top left, top right, bottom right, bottom left */</span>
}
</code></pre>
<p>If only two values are provided, the first value applies to the top-left and bottom-right corner, and the second value applies to the top-right and bottom-left corner.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.leaf-shape</span> {
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">0</span> <span class="hljs-number">50%</span>;
}
</code></pre>
<p>If three values are set, the first again applies to the top-left radius, the second value indicates top-right and bottom-left, leaving the third value to indicate the bottom-right corner.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.odd-shape</span> {
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">0</span> <span class="hljs-number">20px</span> <span class="hljs-number">50%</span>;
}
</code></pre>
<p><img src="https://github.com/kaithrendyle/guide-photos/blob/master/odd-shapes.png?raw=true" alt="examples" width="600" height="400" loading="lazy"></p>
<p>The rounding of a corner does not have to be perfectly symmetrical. You may specify both the horizontal and vertical radiuses using a slash (”/”) to achieve a corner with an elliptical shape.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.elliptical-1</span> {
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">50px</span>/<span class="hljs-number">10px</span>; <span class="hljs-comment">/* horizontal radius / vertical radius */</span>
}
<span class="hljs-selector-class">.elliptical-2</span> {
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">10px</span>/<span class="hljs-number">50px</span>; 
}
</code></pre>
<p><img src="https://github.com/kaithrendyle/guide-photos/blob/master/elliptical-basic.png?raw=true" alt="examples" width="600" height="400" loading="lazy"></p>
<p>Since only one pair of values is given in the above examples, all four corners are the same. But, of course, if you want a more complex shape, you may supply up to four values for the horizontal radiuses and four for the vertical radiuses.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.elliptical-3</span> {
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">50px</span> <span class="hljs-number">20px</span> <span class="hljs-number">50px</span> <span class="hljs-number">20px</span>/<span class="hljs-number">20px</span> <span class="hljs-number">50px</span> <span class="hljs-number">20px</span> <span class="hljs-number">50px</span>; <span class="hljs-comment">/* horizontal top-left, horizontal top-right, horizontal bottom-right, horizontal bottom-left / vertical top-left, vertical top-right, vertical bottom-right, vertical bottom-left */</span>
}
</code></pre>
<p>Notice how the shorthand above produces the same result as specifying individual properties below. Be aware that when corners are set individually the values are space-separated instead of slash-separated.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.elliptical-4</span> {
  <span class="hljs-attribute">border-top-left-radius</span>: <span class="hljs-number">50px</span> <span class="hljs-number">20px</span>; <span class="hljs-comment">/* horizontal radius, vertical radius */</span>
  <span class="hljs-attribute">border-top-right-radius</span>: <span class="hljs-number">20px</span> <span class="hljs-number">50px</span>;
  <span class="hljs-attribute">border-bottom-right-radius</span>: <span class="hljs-number">50px</span> <span class="hljs-number">20px</span>;
  <span class="hljs-attribute">border-bottom-left-radius</span>: <span class="hljs-number">20px</span> <span class="hljs-number">50px</span>;
}
</code></pre>
<p><img src="https://github.com/kaithrendyle/guide-photos/blob/master/elliptical-advance.png?raw=true" alt="examples" width="600" height="400" loading="lazy"></p>
<h2 id="heading-more-info-on-css-border-radius-property">More info on CSS border radius property:</h2>
<ul>
<li><a target="_blank" href="https://www.freecodecamp.org/news/learn-css-border-radius-property-by-building-a-calculator-53497cd8071d/">Learn to use the CSS border radius property by building a calculator</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ CSS Overflow Explained with Examples ]]>
                </title>
                <description>
                    <![CDATA[ The overflow property controls what happens if an element's content overflows from its set width and height. It is shorthand for the overflow-x and overflow-y properties. Note that this property only works for block elements with a specified height. ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/css-overflow-explained-with-examples/</link>
                <guid isPermaLink="false">66c34855d48c8b932b406b3c</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ toothbrush ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 01 Feb 2020 00:00:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9d29740569d1a4ca363e.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The <code>overflow</code> property controls what happens if an element's content overflows from its set width and height. It is shorthand for the <code>overflow-x</code> and <code>overflow-y</code> properties. Note that this property only works for block elements with a specified height.</p>
<p>With <code>overflow</code>, you can control whether to clip content or add scrollbars when an element’s content is too big to fit in a specified area. </p>
<h2 id="heading-values"><strong>Values</strong></h2>
<ul>
<li><code>visible</code>: This is the default value of the property. No content is clipped when it's bigger than its set dimensions.</li>
<li><code>hidden</code>: Content that overflows is hidden.</li>
<li><code>scroll</code>: Content is hidden, but users can still scroll through and view the hidden content.</li>
<li><code>auto</code>: If content is bigger than its set dimensions, content will be hidden automatically and a scrollbar will appear.</li>
<li><code>initial</code>: Uses the default value for this property, <code>visible</code>.</li>
<li><code>inherit</code>: Uses the overflow value of the parent element.</li>
</ul>
<h2 id="heading-examples"><strong>Examples</strong></h2>
<p>Here is the HTML and CSS we'll use for all the following examples:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"box-element"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
    Who's the baby cats are fats i like to pets them they like to meow back. Attack the dog then pretend like nothing happened kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff, see owner, run in terror. Rub face on everything cats are the world. Meow meow, i tell my human i rule on my back you rub my tummy i bite you hard the best thing in the universe is a cardboard box if it smells like fish eat as much as you wish and carefully drink from water glass and then spill it everywhere and proceed to lick the puddle. Paw at beetle and eat it before it gets away rub butt on table for chew foot, or love you, then bite you and pounce on unsuspecting person. What a cat-ass-trophy! cat slap dog in face let me in let me out let me in let me out let me in let me out who broke this door anyway for prance along on top of the garden fence, annoy the neighbor's dog and make it bark and chew iPad power cord purr.
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<pre><code class="lang-css"><span class="hljs-selector-class">.box-element</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">400px</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;
  <span class="hljs-attribute">border</span>: dashed;
}

<span class="hljs-selector-class">.box-element</span> {
  <span class="hljs-comment">/* overflow will be set here */</span>
}
</code></pre>
<h3 id="heading-visible"><strong>Visible:</strong></h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.box-element</span> {
  <span class="hljs-attribute">overflow</span>: visible;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-152.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-hidden"><strong>Hidden:</strong></h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.box-element</span> { 
  <span class="hljs-attribute">overflow</span>: hidden; 
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-153.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-scroll"><strong>Scroll:</strong></h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.box-element</span> { 
  <span class="hljs-attribute">overflow</span>: scroll; 
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-154.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-auto"><strong>Auto:</strong></h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.box-element</span> { 
  <span class="hljs-attribute">overflow</span>: auto; 
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-155.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-overflow-x-and-overflow-y"><strong>overflow-x and overflow-y</strong></h2>
<ul>
<li><code>overflow-x</code>: Allows the user to scroll through the content that extends beyond the height of the box element.</li>
<li><code>overflow-y</code>: Allows the user to scroll through the content that extends beyond the width of the box.</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-class">.box-element</span> {
  <span class="hljs-attribute">overflow-x</span>: scroll;
  <span class="hljs-attribute">overflow-y</span>: auto;
}
</code></pre>
<p>And the <code>.box-element</code> will look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-157.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If the content overflows the Y-axis, then that content will be hidden, whilst a scrollbar should be visible for users to read the rest of the content.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ CSS Linear Gradient Explained with Examples ]]>
                </title>
                <description>
                    <![CDATA[ In a linear gradient, the colors flow in a single direction, for example from left to right, top to bottom, or any angle you choose. A linear gradient with two color stops Syntax To create a linear gradient you must define at least two color stops. ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/css-linear-gradient-explained-with-examples/</link>
                <guid isPermaLink="false">66c3484fc8f6b2d81069b324</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ toothbrush ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 01 Feb 2020 00:00:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9cfc740569d1a4ca3543.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In a linear gradient, the colors flow in a single direction, for example from left to right, top to bottom, or any angle you choose.</p>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371707961422118912/image.png" alt="A gradient with Two colour stops" width="600" height="400" loading="lazy">
<em>A linear gradient with two color stops</em></p>
<h2 id="heading-syntax">Syntax</h2>
<p>To create a linear gradient you must define at least two color stops. They are the colors the transitions are created among. It is declared on either the <strong>background</strong> or <strong>background-image</strong> properties.</p>
<pre><code class="lang-text">background: linear-gradient(direction, colour-stop1, colour-stop2, ...);
</code></pre>
<p>If no direction is specified, the default transition is top to bottom.</p>
<h2 id="heading-examples">Examples</h2>
<h3 id="heading-top-to-bottom">Top to bottom:</h3>
<pre><code class="lang-text">background: linear-gradient(red, yellow);
</code></pre>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371702268803809301/image.png" alt="Top to Bottom" width="600" height="400" loading="lazy"></p>
<p><strong>Left To</strong> r<strong>ight:</strong></p>
<p>To make it left to right, you add an additional parameter at the beginning of the <code>linear-gradient()</code> starting with the word <strong>to</strong> which indicates the direction:</p>
<pre><code class="lang-text">background: linear-gradient(to right, red , yellow);
</code></pre>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371702990161051648/image.png" alt="Left to Right" width="600" height="400" loading="lazy"></p>
<p><strong>Diagonal</strong> gradients<strong>:</strong></p>
<p>You can also transition a gradient diagonally by specifying the horizontal and vertical starting positions, for example, top-left, or bottom-right.</p>
<p>Here’s a sample for a gradient starting from the top-left:</p>
<pre><code class="lang-text"> background: linear-gradient(to bottom right, red, yellow);
</code></pre>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371705382105776128/image.png" alt="Top-left" width="600" height="400" loading="lazy"></p>
<h3 id="heading-using-angles-to-specify-the-direction-of-the-gradient"><strong>Using angles to specify the direction of the gradient</strong></h3>
<p>You can also use angles, to be more accurate in specifying the direction of the gradient:</p>
<pre><code class="lang-text">background: linear-gradient(angle, colour-stop1, colour-stop2);
</code></pre>
<p>The angle is specified as an angle between a horizontal line and the gradient line.</p>
<pre><code class="lang-text">background: linear-gradient(90deg, red, yellow);
</code></pre>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371710718698848256/image.png" alt="90 degrees" width="600" height="400" loading="lazy"></p>
<h3 id="heading-using-more-than-two-colors"><strong>Using more than two colors</strong></h3>
<p>You’re not limited to just two colors – you can use as many comma separated colors as you want.</p>
<pre><code class="lang-text">background: linear-gradient(red, yellow, green);
</code></pre>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371706534591201281/image.png" alt="A gradient with 3 colour stops" width="600" height="400" loading="lazy"></p>
<p>You can also use other color syntaxes like RGB or hex codes to specify the colors.</p>
<h3 id="heading-hard-color-stops"><strong>Hard color stops</strong></h3>
<p>You can not only use gradients to transition with fading colors, but you can also use it to change from one solid color to another solid color instantly:</p>
<pre><code class="lang-text">background: linear-gradient(to right,red 15%, yellow 15%);
</code></pre>
<p><img src="https://cdn.discordapp.com/attachments/261391445074771978/371716730046775318/image.png" alt="Hard colour stops" width="600" height="400" loading="lazy"></p>
<h2 id="heading-more-information">More information:</h2>
<ul>
<li><a target="_blank" href="https://www.freecodecamp.org/news/the-css-handbook-a-handy-guide-to-css-for-developers-b56695917d11/">The CSS Handbook: a handy guide to CSS for developers</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ CSS Comment Example – How To Comment Out CSS ]]>
                </title>
                <description>
                    <![CDATA[ Comments are used in CSS to explain a block of code or to make temporary changes during development. The commented code doesn’t execute. Both single and multi-line comments in CSS begin with /* and end with */, and you can add as many comments to you... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/comments-in-css/</link>
                <guid isPermaLink="false">66c3479b4f1fc448a3678fcb</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ style ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 26 Jan 2020 21:57:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9d7b740569d1a4ca3800.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Comments are used in CSS to explain a block of code or to make temporary changes during development. The commented code doesn’t execute.</p>
<p>Both single and multi-line comments in CSS begin with <code>/*</code> and end with <code>*/</code>, and you can add as many comments to your stylesheet as you like. For example:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* This is a single line comment*/</span>
<span class="hljs-selector-class">.group</span><span class="hljs-selector-pseudo">:after</span> {
  <span class="hljs-attribute">content</span>: <span class="hljs-string">""</span>;
  <span class="hljs-attribute">display</span>: table;
  <span class="hljs-attribute">clear</span>: both;
}

<span class="hljs-comment">/*
  This is
  a multi-line
  comment
*/</span>
</code></pre>
<p>You can also make your comments more readable by stylizing them:</p>
<pre><code class="lang-css"><span class="hljs-comment">/*
***
* SECTION FOR H2 STYLE 
***
* A paragraph with information
* that would be useful for someone
* who didn't write the code.
* The asterisks around the paragraph 
* help make it more readable.
***
*/</span>
</code></pre>
<h2 id="heading-organizing-css-with-comments">Organizing CSS with comments</h2>
<p>In larger projects, CSS files can quickly grow in size and become difficult to maintain. It can be helpful to organize your CSS into distinct sections with a table of contents to make it easier to find certain rules in the future:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* 
*  CSS TABLE OF CONTENTS
*   
*  1.0 - Reset
*  2.0 - Fonts
*  3.0 - Globals
*  4.0 - Color Palette
*  5.0 - Header
*  6.0 - Body
*    6.1 - Sliders
*    6.2 - Imagery
*  7.0 - Footer
*/</span>

<span class="hljs-comment">/*** 1.0 - Reset ***/</span>

<span class="hljs-comment">/*** 2.0 - Fonts ***/</span>

<span class="hljs-comment">/*** 3.0 - Globals ***/</span>

<span class="hljs-comment">/*** 4.0 - Color Palette ***/</span>

<span class="hljs-comment">/*** 5.0 - Header ***/</span>

<span class="hljs-comment">/*** 6.0 - Body ***/</span>
<span class="hljs-selector-tag">h2</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1.2em</span>;
  <span class="hljs-attribute">font-family</span>: <span class="hljs-string">"Ubuntu"</span>, serif;
  <span class="hljs-attribute">text-transform</span>: uppercase;
}

<span class="hljs-comment">/*** 5.1 - Sliders ***/</span>

<span class="hljs-comment">/*** 5.2 - Imagery ***/</span>

<span class="hljs-comment">/*** 7.0 - Footer ***/</span>
</code></pre>
<h2 id="heading-a-little-bit-more-about-css-css-syntax-and-selectors">A little bit more about CSS: <strong>CSS Syntax and Selectors</strong></h2>
<p>When we talk about the syntax of CSS, we’re talking about how things are laid out. There are rules about what goes where, both so you can write CSS consistently and a program (like a browser) can interpret it and apply it to the page correctly.</p>
<p>There are two main ways to write CSS.</p>
<h3 id="heading-inline-css"><strong>Inline CSS</strong></h3>
<p>Specifics on CSS Specificity: <a target="_blank" href="https://css-tricks.com/specifics-on-css-specificity/">CSS Tricks</a></p>
<p>Inline CSS applies styling to a single element and its children, until another style overriding the first is encountered.</p>
<p>To apply inline CSS, add the “style” attribute to an HTML element that you’d like to modify. Inside quotes, include a semicolon-delimited list of key/value pairs (each in turn separated by a colon) indicating styles to set.</p>
<p>Here’s an example of inline CSS. The words “One” and “Two” will have a background color of yellow and text color of red. The word “Three” has a new style that overrides the first, and will have a background color of green and text color of cyan. In the example, we’re applying styles to <code>&lt;div&gt;</code> tags, but you can apply a style to any HTML element.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"color:red; background:yellow"</span>&gt;</span>
  One
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Two
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"color:cyan; background:green"</span>&gt;</span>
    Three
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-internal-css"><strong>Internal CSS</strong></h3>
<p>While writing an inline style is a quick way to change a single element, there’s a more efficient way to apply the same style to many elements of the page at once.</p>
<p>The internal CSS has its styles specified in the <code>&lt;style&gt;</code> tag, and it is embedded in the <code>&lt;head&gt;</code> tag.</p>
<p>Here’s an example that has a similar effect as the “inline” example above, except the CSS has been extracted to its own area. The words “One” and “Two” will match the <code>div</code> selector and be red text on a yellow background. The words “Three” and “Four” will match the <code>div</code> selector too, but they also match the <code>.nested_div</code> selector which applies to any HTML element that references that class. This more specific selector overrides the first, and they end up appearing as cyan text on a green background.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/css"</span>&gt;</span><span class="css">
  <span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">color</span>: red; <span class="hljs-attribute">background</span>: yellow; }
  <span class="hljs-selector-class">.nested_div</span> { <span class="hljs-attribute">color</span>: cyan; <span class="hljs-attribute">background</span>: green; }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  One
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Two
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"nested_div"</span>&gt;</span>
    Three
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"nested_div"</span>&gt;</span>
    Four
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The selectors shown above are extremely simple, but they can get quite complex. For example, it’s possible to apply styles only to nested elements; that is, an element that’s a child of another element.</p>
<p>Here’s an example where we’re specifying a style that should only be applied to <code>div</code> elements that are a direct child of other <code>div</code> elements. The result is that “Two” and “Three” will appear as red text on a yellow background, but “One” and “Four” will remain unaffected (and most likely black text on a white background).</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/css"</span>&gt;</span><span class="css">
  <span class="hljs-selector-tag">div</span> &gt; <span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">color</span>: red; <span class="hljs-attribute">background</span>: yellow; }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  One
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Two
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Three
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  Four
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-external-css"><strong>External CSS</strong></h3>
<p>All the styling has its own document which is linked in the <code>&lt;head&gt;</code> tag. The extension of the linked file is <code>.css</code></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ CSS Text Shadow and Box Shadow Effects (with Examples) ]]>
                </title>
                <description>
                    <![CDATA[ With CSS3 you can create two types of shadows: text-shadow (adds shadow to text) and box-shadow (adds shadow to other elements). CSS3 Text Shadow The text-shadow property can take up to four values: the horizontal shadow the vertical shadow the blur... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/css-text-shadow-and-box-shadow-examples/</link>
                <guid isPermaLink="false">66c3486bc8f6b2d81069b329</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 10 Jan 2020 19:38:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9dfe740569d1a4ca3ac9.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>With CSS3 you can create two types of shadows: <code>text-shadow</code> (adds shadow to text) and <code>box-shadow</code> (adds shadow to other elements).</p>
<h3 id="heading-css3-text-shadow"><strong>CSS3 Text Shadow</strong></h3>
<p>The <code>text-shadow</code> property can take up to four values:</p>
<ul>
<li>the horizontal shadow</li>
<li>the vertical shadow</li>
<li>the blur effect</li>
<li>the color</li>
</ul>
<h5 id="heading-examples"><strong>Examples:</strong></h5>
<p>Normal text shadow</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span> {
<span class="hljs-attribute">text-shadow</span>: <span class="hljs-number">2px</span> <span class="hljs-number">2px</span> <span class="hljs-number">5px</span> crimson;
}
</code></pre>
<p><img src="https://raw.githubusercontent.com/nawnaw7/FCC-guides-CSS3-shadows-images/master/CSS3%20Shadow%20Effects%20Images/text-shadow1.png" alt="Normal text shadow example" width="428" height="128" loading="lazy"></p>
<p>Glowing text effect</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span> {
<span class="hljs-attribute">text-shadow</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">4px</span> <span class="hljs-number">#00FF9C</span>;
}
</code></pre>
<p><img src="https://raw.githubusercontent.com/nawnaw7/FCC-guides-CSS3-shadows-images/master/CSS3%20Shadow%20Effects%20Images/text-shadow2.png" alt="Glowing text example" width="321" height="129" loading="lazy"></p>
<h4 id="heading-multiple-shadows"><strong>Multiple Shadows</strong></h4>
<p>To achieve this, you simply add a comma between two (or more) sets of values:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span> {
    <span class="hljs-attribute">color</span>: white;
    <span class="hljs-attribute">text-shadow</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">3px</span> <span class="hljs-number">#F10D58</span>, <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">7px</span> <span class="hljs-number">#4578D5</span>;
}
</code></pre>
<p><img src="https://raw.githubusercontent.com/nawnaw7/FCC-guides-CSS3-shadows-images/master/CSS3%20Shadow%20Effects%20Images/text-shadow3.png" alt="Multiple shadows examaple with white text" width="388" height="113" loading="lazy"></p>
<h3 id="heading-css3-box-shadow"><strong>CSS3 Box Shadow</strong></h3>
<p>The <code>box-shadow</code> property can take up to six values:</p>
<ul>
<li>(optional) the <code>inset</code> keyword (changes the shadow to one inside the frame)</li>
<li>the horizontal shadow</li>
<li>the vertical shadow</li>
<li>the blur effect</li>
<li>the spreading</li>
<li>the color</li>
</ul>
<h5 id="heading-examples-1"><strong>Examples:</strong></h5>
<pre><code class="lang-css"><span class="hljs-selector-class">.first-div</span> {
    <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">1px</span> <span class="hljs-number">1px</span> <span class="hljs-number">5px</span> <span class="hljs-number">3px</span> grey;
}

<span class="hljs-selector-class">.second-div</span> {
    <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">5px</span> <span class="hljs-number">1px</span> lightgrey;
}

<span class="hljs-selector-class">.third-div</span> {
    <span class="hljs-attribute">box-shadow</span>: inset <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">15px</span> <span class="hljs-number">5px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0.75</span>);
}
</code></pre>
<p><img src="https://raw.githubusercontent.com/nawnaw7/FCC-guides-CSS3-shadows-images/master/CSS3%20Shadow%20Effects%20Images/box-shadows.png" alt="Box-shadow examples" width="397" height="607" loading="lazy"></p>
<h4 id="heading-more-information"><strong>More Information:</strong></h4>
<ul>
<li><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow?v=b">MDN web docs</a></li>
<li><a target="_blank" href="https://caniuse.com/#search=box-shadow">Check for browser support</a></li>
<li><a target="_blank" href="https://www.cssmatic.com/box-shadow">CSS box-shadow generator</a> (feel free to experiment with box-shadows)</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Best CSS and CSS3 Tutorials ]]>
                </title>
                <description>
                    <![CDATA[ Cascading Style Sheets (CSS) CSS is an acronym for Cascading Style Sheets. It was first invented in 1996, and is now a standard feature of all major web browsers. CSS allows for developers to control how web pages look by “styling” the HTML structure... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/best-css-and-css3-tutorial/</link>
                <guid isPermaLink="false">66c3458342d4db64acf4cbe8</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tutorial ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 25 Nov 2019 00:43:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9f10740569d1a4ca409f.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <h3 id="heading-cascading-style-sheets-css"><strong>Cascading Style Sheets (CSS)</strong></h3>
<p>CSS is an acronym for Cascading Style Sheets. It was first invented in 1996, and is now a standard feature of all major web browsers.</p>
<p>CSS allows for developers to control how web pages look by “styling” the HTML structure of that page.</p>
<p>CSS specifications are maintained by the <a target="_blank" href="https://www.w3.org/">World Wide Web Consortium (W3C)</a>.</p>
<p>You can build some pretty amazing things in CSS alone, such as this pure-CSS <a target="_blank" href="https://codepen.io/bali_balo/pen/BLJONk">Minesweeper game</a> (which uses no JavaScript).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*GFcKk9KxqHAnWa1ECcKDOQ.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>A good start is the freeCodeCamp curriculum <a target="_blank" href="https://learn.freecodecamp.org/responsive-web-design/basic-css">Introduction to Basic CSS</a>.</p>
<p>Another suggestion for beginners is W3C’s <a target="_blank" href="https://www.w3.org/Style/Examples/011/firstcss">Starting with HTML + CSS</a> which teaches how to create a style sheet.</p>
<p>The site <a target="_blank" href="http://www.csszengarden.com/">CSS Zen Garden</a> is a great example how the same html can be styled to look totally unique.</p>
<p>For a demonstration of the power of CSS, check out <a target="_blank" href="http://species-in-pieces.com/#">Species In Pieces</a>.</p>
<h1 id="heading-tutorials-for-starting-with-css-and-css3">Tutorials for starting with CSS and CSS3</h1>
<p>The best place to start learning CSS is with freeCodeCamp's <a target="_blank" href="https://www.youtube.com/watch?v=ieTHC78giGQ">2-hour intro to CSS tutorial</a>.</p>
<p>Then, if you're feeling more adventurous, we have an entire <a target="_blank" href="https://www.youtube.com/watch?v=mU6anWqZJcc">12-hour course that covers HTML, HTML5, and CSS in detail</a>.</p>
<p><img src="https://img.youtube.com/vi/mU6anWqZJcc/maxresdefault.jpg" alt="Image" width="1280" height="720" loading="lazy"></p>
<h2 id="heading-flexbox"><strong>Flexbox</strong></h2>
<p>Flexbox is a new way to structure content in CSS3. It provides a wonderful way to create responsive websites that work well across different screen sizes and order content.</p>
<p>There are 3 simple steps to use Flexbox:</p>
<ol>
<li>Convert the parent container to a flex container by using <code>display: flex;</code></li>
<li>Adjust the layout of different containers by using <code>flex-direction</code></li>
<li>Adjust the layout of items within a container by using properties like <code>justify-content</code>, <code>align-items</code>, and so on</li>
</ol>
<p>Flexbox allows you to efficiently lay out, align, and adjust the space among different page elements, even if you don't know their exact size. Instead, items and containers are dynamic, and will "flex" to best fill the available space.  </p>
<ul>
<li><strong>main-axis</strong>: The primary axis of a flex container along which flex items are laid out. Keep in mind that this can be horizontal or vertical depending on the <code>flex-direction</code> property.</li>
<li><strong>main-start | main-end</strong>: Flex items are placed in a container from <code>main-start</code> to <code>main-end</code>.</li>
<li><strong>main size</strong>: A flex item's main dimension, which can be its width or height, acts as the item's main size.</li>
<li><strong>cross axis</strong>: The axis that is perpendicular to the main axis. The direction of the cross axis depends on the main axis's direction.</li>
<li><strong>cross-start | cross-end</strong>: Flex lines and items are placed in a flex container starting from the <code>cross-start</code> to the <code>cross-end</code> side.</li>
<li><strong>cross size</strong>: The item's cross dimension (width or height) acts as the item's cross size.</li>
</ul>
<h2 id="heading-grid-layout"><strong>Grid Layout</strong></h2>
<p>CSS Grid Layout, simply known as Grid, is a layout scheme that is the newest and the most powerful in CSS. It is <a target="_blank" href="https://caniuse.com/#feat=css-grid">supported by all major browsers</a> and provides a way to position items on the page and move them around.</p>
<p>It can automatically assign items to <em>areas</em>, size and resize them, take care of creating columns and rows based on a pattern you define, and it does all the calculations using the newly introduced <code>fr</code> unit.</p>
<h3 id="heading-why-grid"><strong>Why Grid?</strong></h3>
<ul>
<li>You can easily have a 12-column grid with one line of CSS. <code>grid-template-columns: repeat(12, 1fr)</code></li>
<li>Grid lets you move things in any direction. Unlike Flex, where you can move items either horizontally (<code>flex-direction: row</code>) or vertically (<code>flex-direction: column</code>) - and not both at the same time - Grid lets you move any <em>grid item</em> to any predefined <em>grid area</em> on the page. The items you move do not have to be adjacent.</li>
<li>With CSS Grid, you can <strong>change the order of HTML elements using only CSS</strong>. Move something from top to the right, move elements that were in the footer to the sidebar etc. Instead of moving the <code>&lt;div&gt;</code>from <code>&lt;footer&gt;</code> to <code>&lt;aside&gt;</code> in the HTML, you can just change its placement with <code>grid-area</code> in the CSS stylesheet.</li>
</ul>
<h3 id="heading-grid-vs-flex"><strong>Grid vs. Flex</strong></h3>
<ul>
<li>Flex is one-dimensional - either horizontal or vertical, while Grid is two-dimensional, meaning you can move elements in both horizontal and vertical planes</li>
<li>In Grid, we apply layout styles to the parent container and not the items. Flex, on the other hand, targets the flex item to set properties like <code>flex-basis</code>, <code>flex-grow</code>, and <code>flex-shrink</code></li>
<li>Grid and Flex are not mutually exclusive. You can use both on the same project.</li>
</ul>
<h3 id="heading-checking-browser-compatibility-with-supports"><strong>Checking browser compatibility with <code>@supports</code></strong></h3>
<p>Ideally, when you build a site, you’d design it with Grid and use Flex as a fallback. You can find out if your browser supports grid with the <code>@support</code> CSS rule (aka feature query). Here’s an example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.container</span> {
  <span class="hljs-attribute">display</span>: grid; <span class="hljs-comment">/* display grid by default */</span>
}

<span class="hljs-keyword">@supports</span> <span class="hljs-keyword">not</span> (<span class="hljs-attribute">display:</span> grid) { <span class="hljs-comment">/* if grid is not supported by the browser */</span>
  <span class="hljs-selector-class">.container</span> {
    <span class="hljs-attribute">display</span>: flex; <span class="hljs-comment">/* display flex instead of grid */</span>
  }
}
</code></pre>
<h3 id="heading-getting-started"><strong>Getting Started</strong></h3>
<p>To make any element a grid, you need to assign its <code>display</code> property to <code>grid</code>, like so:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.conatiner</span> {
  <span class="hljs-attribute">display</span>: grid;
}
</code></pre>
<p>And that’s it. You just made your <code>.container</code> a grid. Every element inside the <code>.container</code> automatically becomes a grid item.</p>
<h3 id="heading-defining-templates"><strong>Defining templates</strong></h3>
<p>Rows and columns</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">grid-template-columns</span>: 1<span class="hljs-selector-tag">fr</span> 1<span class="hljs-selector-tag">fr</span> 1<span class="hljs-selector-tag">fr</span> 1<span class="hljs-selector-tag">fr</span>;
<span class="hljs-selector-tag">grid-template-rows</span>: <span class="hljs-selector-tag">auto</span> 300<span class="hljs-selector-tag">px</span>;
</code></pre>
<p>Areas</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">grid-template-areas</span>: 
  "<span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">a</span>"
  "<span class="hljs-selector-tag">b</span> <span class="hljs-selector-tag">c</span> <span class="hljs-selector-tag">d</span> <span class="hljs-selector-tag">e</span>"
  "<span class="hljs-selector-tag">b</span> <span class="hljs-selector-tag">c</span> <span class="hljs-selector-tag">d</span> <span class="hljs-selector-tag">e</span>"
  "<span class="hljs-selector-tag">f</span> <span class="hljs-selector-tag">f</span> <span class="hljs-selector-tag">f</span> <span class="hljs-selector-tag">f</span>";
</code></pre>
<p>or</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">grid-template-areas</span>:
  "<span class="hljs-selector-tag">header</span> <span class="hljs-selector-tag">header</span> <span class="hljs-selector-tag">header</span> <span class="hljs-selector-tag">header</span>"
  "<span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">main</span> <span class="hljs-selector-tag">main</span> <span class="hljs-selector-tag">sidebar</span>";
</code></pre>
<h3 id="heading-grid-areas"><strong>Grid Areas</strong></h3>
<p>Here’s some sample code on how to define and assign grid areas:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.site</span> {
  <span class="hljs-attribute">display</span>: grid;
  <span class="hljs-attribute">grid-template-areas</span>: <span class="hljs-comment">/* applied to grid container */</span>
    <span class="hljs-string">"head head"</span> <span class="hljs-comment">/* you're assigning cells to areas by giving the cells an area name */</span>
    <span class="hljs-string">"nav  main"</span> <span class="hljs-comment">/* how many values kind of depends on how many cells you have in the grid */</span>
    <span class="hljs-string">"nav  foot"</span>;
}

<span class="hljs-selector-class">.site</span> &gt; <span class="hljs-selector-tag">header</span> {
  <span class="hljs-attribute">grid-area</span>: head;
}

<span class="hljs-selector-class">.site</span> &gt; <span class="hljs-selector-tag">nav</span> {
  <span class="hljs-attribute">grid-area</span>: nav;
}

<span class="hljs-selector-class">.site</span> &gt; <span class="hljs-selector-tag">main</span> {
    <span class="hljs-attribute">grid-area</span>: main;
}

<span class="hljs-selector-class">.site</span> &gt; <span class="hljs-selector-tag">footer</span> {
    <span class="hljs-attribute">grid-area</span>: foot;
}
</code></pre>
<h3 id="heading-the-fr-unit"><strong>The <code>fr</code> unit</strong></h3>
<p>Grid introduces a new <code>fr</code> unit, which stands for <em>fraction</em>. The good thing about using the <code>fr</code> unit is that it takes care of calculations for you. Using <code>fr</code> avoids margin and padding issues. With <code>%</code> and <code>em</code> etc. it becomes a math equation when calculating <code>grid-gap</code>. If you used <code>fr</code> unit, it’ll automatically calculate both column and gutter sizes and adjust the size of the columns accordingly. Plus there will be no bleeding gaps at the end either.</p>
<h2 id="heading-examples">Examples</h2>
<h4 id="heading-changing-the-order-of-elements-based-on-screen-size"><strong>Changing the order of elements based on screen size</strong></h4>
<p>Let’s say you want to move the footer to the bottom on small screens and to the right on bigger screens, and there’s a bunch of other HTML elements in between the two.</p>
<p>The simple solution is to change the <code>grid-template-areas</code> based on the screen size. You can also <strong>change the number of columns and rows based on the screen size</strong>, too. This is a much cleaner and simpler alternative to Bootstrap’s Grid system (<code>col-xs-8 col-sm-6 col-md-4 col-lg-3</code>).</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.site</span> {
  <span class="hljs-attribute">display</span>: grid;
  <span class="hljs-attribute">grid-template-columns</span>: <span class="hljs-number">1</span>fr <span class="hljs-number">1</span>fr;
  <span class="hljs-attribute">grid-template-areas</span>:
    <span class="hljs-string">"title title"</span>
    <span class="hljs-string">"main header"</span>
    <span class="hljs-string">"main sidebar"</span>
}

<span class="hljs-keyword">@media</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">34em</span>) { <span class="hljs-comment">/* If the screen is big enough, use a different template for grid areas */</span>
  <span class="hljs-selector-class">.site</span> {
    <span class="hljs-attribute">grid-template-columns</span>: <span class="hljs-number">2</span>fr <span class="hljs-number">1</span>fr <span class="hljs-number">1</span>fr;
    <span class="hljs-attribute">grid-template-areas</span>:
      <span class="hljs-string">"title title title"</span>
      <span class="hljs-string">"main header header"</span>
      <span class="hljs-string">"main sidebar footer"</span>
  }
}
</code></pre>
<h4 id="heading-more-information"><strong>More Information:</strong></h4>
<ul>
<li><a target="_blank" href="https://mozilladevelopers.github.io/playground/">CSS Grid Palyground by Mozilla</a>: Great starting point if you’re new to CSS Grids. It has visuals to help you understand the terminology easily</li>
<li><a target="_blank" href="https://www.youtube.com/watch?v=txZq7Laz7_4">YouTube: Morten Rand-Hendriksen: CSS Grid Changes Everything (About Web Layouts)</a>: This presentation will convince you in less than an hour why CSS Grids are cool and why/how you should use them.</li>
<li><a target="_blank" href="https://gridbyexample.com/video/">Videos: Learn Grid Layout Video Series by Rachel Andrew</a>: Rachel Andrew is an expert on the subject. The video titles may look strange and overwhelming, but the content is short and to the point</li>
<li><a target="_blank" href="https://abookapart.com/products/get-ready-for-css-grid-layout">Book: Get Ready for CSS Grid Layout by Rachel Andrew</a></li>
</ul>
<h1 id="heading-selectors"><strong>Selectors</strong></h1>
<p>Selectors are CSS rules to target HTML elements to apply styles. Tag names, class names, ids, and attributes are some of the hooks used as selectors.</p>
<h2 id="heading-selector-syntax"><strong>Selector Syntax</strong></h2>
<p>Selectors arranged in a specific sequence build up to a rule to target elements. An example:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* selects anchor tags */</span>
<span class="hljs-selector-tag">a</span> { 
    <span class="hljs-attribute">color</span>: orange;
}

<span class="hljs-comment">/* selects elements with hero class */</span>
<span class="hljs-selector-class">.hero</span> {
    <span class="hljs-attribute">text-align</span>: center;
}
</code></pre>
<h2 id="heading-type-of-selectors"><strong>Type of Selectors</strong></h2>
<ul>
<li>TypeDescription are Type selectors and Tag names are used to select elements such as <code>h1</code> or <code>a</code>. </li>
<li>Universal Selectors apply to all elements.</li>
<li><code>div *</code> matches all elements within div elements. </li>
<li>Attribute Selectors are Selectors that target elements based on their attributes [and optionally, their values].</li>
<li><code>h1[title]</code> selects <code>h1</code> elements with <code>title</code> attribute. </li>
<li>Class Selectors are Selectors that target elements using their class names. </li>
<li>ID Selectors are Selectors that use ID to target elements. <code>#logo</code> selects the element with <code>logo</code> as ID. </li>
<li>Pseudo-class Selectors are Special selectors that target elements based on their state. <code>a:hover</code> selector applies style when pointer hovers over links.</li>
</ul>
<h2 id="heading-selector-combinators"><strong>Selector Combinators</strong></h2>
<p>Combinator: Purpose <code>white space</code>Descendant combinator. <code>.nav li</code> selects all <code>li</code> children within the class <code>.nav</code>, including nested <code>li</code> elements.<code>&gt;</code>Child combinator. <code>.menu &gt; li</code> selects all li that are direct children of elements with <code>.menu</code> class.<code>+</code>Adjacent sibling combinator. <code>.logo + h1</code> targets <code>h1</code> that is an immediate sibling to <code>.logo</code> class.<code>~</code>General sibling combinator. <code>header ~ div</code> targets <code>div</code> elements that are siblings to <code>header</code> elements.</p>
<p>This section details all of these electors.</p>
<h4 id="heading-more-information-1"><strong>More Information:</strong></h4>
<p>You can learn more about selectors on these resources:</p>
<ul>
<li><a target="_blank" href="https://www.w3.org/TR/css3-selectors">Official CSS3 Selectors specification</a></li>
<li><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors">Selectors page on Mozilla Developer Network</a></li>
<li><a target="_blank" href="https://guide.freecodecamp.org/css/tutorials/css-selectors-cheat-sheet">CSS Selectors Cheat Sheet on FreeCodeCamp Guides</a></li>
</ul>
<p>Selectors in CSS (cascading style sheets) are determined based on <em>specificity.</em> With this we are able to be more specific on our style rules and override other rules that may be targeting the same element but are not as specific. </p>
<p>The way this specificity hierarchy works is based on weight. This means that an element Selector has a weight of 1 (one), a class selector has a weight of 10 (ten) and a id selector has a weight of 100 (one hundred). We are able to combine different selectors together be more specific on the element we want to change.</p>
<p>As an example:</p>
<pre><code class="lang-css">    <span class="hljs-selector-tag">p</span> {
      <span class="hljs-attribute">color</span>: blue;
    }
    <span class="hljs-selector-tag">p</span> <span class="hljs-selector-class">.red</span> {
       <span class="hljs-attribute">color</span>: red;
    }
</code></pre>
<p>Our type selector p will select all p elements in our html document, but it only has a weight of one. In contrast, the class selector has a weight of 11, because we are combining a type selector with a class selector (this selector is matching all p elements with a class of red). </p>
<p>Note: </p>
<ul>
<li>Directly targeted rules will always have precedence over rules which inherit elements from their ancestor. </li>
<li>Specificity is only applied when multiple declarations are targeting the same element, and only then this rule is applied.</li>
<li>Specificity is usually why some of the style rules do not apply to elements when you would expect them to.</li>
</ul>
<h2 id="heading-css-display"><strong>CSS Display</strong></h2>
<p>The display property specifies the type of box used for an HTML element. It has 20 possible keyword values. The commonly used ones are:</p>
<pre><code class="lang-css">    <span class="hljs-selector-class">.none</span>             {<span class="hljs-attribute">display</span>: none}
    <span class="hljs-selector-class">.block</span>            {<span class="hljs-attribute">display</span>: block}
    <span class="hljs-selector-class">.inline-block</span>     {<span class="hljs-attribute">display</span>: inline-block}
    <span class="hljs-selector-class">.inline</span>           {<span class="hljs-attribute">display</span>: inline}
    <span class="hljs-selector-class">.flex</span>             {<span class="hljs-attribute">display</span>: flex}
    <span class="hljs-selector-class">.inline-flex</span>      {<span class="hljs-attribute">display</span>: inline-flex}
    <span class="hljs-selector-class">.inline-table</span>     {<span class="hljs-attribute">display</span>: inline-table}
    <span class="hljs-selector-class">.table</span>            {<span class="hljs-attribute">display</span>: table}
    <span class="hljs-selector-class">.inherit</span>          {<span class="hljs-attribute">display</span>: inherit}
    <span class="hljs-selector-class">.initial</span>          {<span class="hljs-attribute">display</span>: initial}
</code></pre>
<p>The <code>display:none</code> property can often be helpful when making a website responsive. For example, you may want to hide an element on a page as the screen size shrinks in order to compensate for the lack of space. <code>display: none</code> will not only hide the element, but all other elements on the page will behave as if that element does not exist. </p>
<p>This is the biggest difference between this property and the <code>visibility: hidden</code> property, which hides the element but keeps all other page elements in the same place as they would appear if the hidden element was visible.</p>
<p>These keyword values are grouped into six categories:</p>
<ul>
<li><code>&lt;display-inside&gt;</code></li>
<li><code>&lt;display-outside&gt;</code></li>
<li><code>&lt;display-listitem&gt;</code></li>
<li><code>&lt;display-box&gt;</code></li>
<li><code>&lt;display-internal&gt;</code></li>
<li><code>&lt;display-legacy&gt;</code></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Best CSS Examples and CSS3 Examples ]]>
                </title>
                <description>
                    <![CDATA[ CSS provides the style of a website. The background property lets you use images and colors to create backgrounds for your web pages. Background Color Example The background color property allows you to choose the color of your element. This can be t... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/css-example-css3/</link>
                <guid isPermaLink="false">66c34840c8f6b2d81069b320</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 18 Nov 2019 17:46:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9f3c740569d1a4ca4181.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>CSS provides the style of a website.</p>
<p>The background property lets you use images and colors to create backgrounds for your web pages.</p>
<h3 id="heading-background-color-example"><strong>Background Color Example</strong></h3>
<p>The background color property allows you to choose the color of your element. This can be the background for the entire page or the background of one section of your page.</p>
<ul>
<li>An element is a piece of HTML such as a header or paragraph on a web page.</li>
</ul>
<p>Here is an example of setting the background color for a web page to green.</p>
<pre><code class="lang-css">  <span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">background-color</span>: green;
  }
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/green-bg-100-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Here is an example of setting the colors for two elements. This will set the background of the header to purple and the rest of the page to blue.</p>
<pre><code class="lang-css">  <span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">background-color</span>: blue;
  }
  <span class="hljs-selector-tag">h1</span> {
    background–<span class="hljs-attribute">color</span>: purple;
  }
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/31036152-0607936a-a539-11e7-9e9f-a5e60ade042d.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In CSS, color can be defined in three ways:</p>
<ul>
<li>A valid color name such as <code>blue</code></li>
<li>A HEX value such as <code>#FFFFF</code> (This is the hex value for white.)</li>
<li>An RGB value such as <code>rgb(76,175,80)</code> (This is the RGB value for light green.)</li>
</ul>
<h3 id="heading-background-images"><strong>Background Images</strong></h3>
<p>You can use the background image property to set an image as a background for an element. The image is repeated by default so that it covers the entire element.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>);
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/31036366-eb1fc260-a539-11e7-835d-e3f935a22c86.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can also link pictures or gifs that you find online by using their link (for example, from a Google Images search).</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"https://mdn.mozillademos.org/files/11983/starsolid.gif"</span>);
}
</code></pre>
<h3 id="heading-background-image-the-repeat-property"><strong>Background Image - The Repeat Property</strong></h3>
<p>The background image is repeated both vertically (up and down) and horizontally (across the web page) by default. You can use the background-repeat property to repeat the image vertically or horizontally.</p>
<p>Here is an example that repeats the image vertically:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>);
  <span class="hljs-attribute">background-repeat</span>: repeat-y;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/31039770-8962c7a6-a54e-11e7-9d25-4fb09760d219.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can repeat the image horizontally by setting the background-repeat property to “repeat-x”.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>);
  <span class="hljs-attribute">background-repeat</span>: repeat-x;
}
</code></pre>
<p>You can also use the background-repeat property to set an image to not repeat.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>);
  <span class="hljs-attribute">background-repeat</span>: no-repeat;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/31039801-c8761efc-a54e-11e7-8bb9-ec5b88885a50.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-background-image-the-position-property"><strong>Background Image – The Position Property</strong></h3>
<p>You can use the position property to specify where your image will be located on a web page.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>);
  <span class="hljs-attribute">background-repeat</span>: no-repeat;
  <span class="hljs-attribute">background-position</span>: right top;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/31039828-077d1038-a54f-11e7-8aa6-092253ca92b8.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-background-image-the-fixed-position"><strong>Background Image – The Fixed Position</strong></h3>
<p>You can use the background-attachment property to set an image to a fixed position. A fixed position makes it so an image does not scroll with the rest of the page.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>);
  <span class="hljs-attribute">background-repeat</span>: no-repeat;
  <span class="hljs-attribute">background-position</span>: right top;
  <span class="hljs-attribute">background-attachment</span>: fixed;
}
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/31039859-39612c92-a54f-11e7-93ca-9d7bcb938225.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-background-gradients"><strong>Background Gradients</strong></h3>
<p>A gradient is a transition between two or more colors and can be used via CSS similar to a background image.</p>
<p>The syntax of a gradient background can be quite complex and is often still used with vendor prefixes due to inconsistencies between supported browsers.</p>
<p>The <a target="_blank" href="http://www.colorzilla.com/gradient-editor/">Colorzilla Gradient Editor</a> is a great online tool for generating custom gradients and the associated CSS markup.</p>
<h3 id="heading-background-the-shorthand-property"><strong>Background – The Shorthand Property</strong></h3>
<p>You can write the background properties on a single line. This is called the shorthand property.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>) no-repeat right top;
}
</code></pre>
<p>You can leave out properties you don’t need when using the shorthand property, but the properties must be used in a certain order. The order is:</p>
<ul>
<li>color</li>
<li>image</li>
<li>repeat</li>
<li>attachment</li>
<li>position</li>
</ul>
<h3 id="heading-multiple-background-images"><strong>Multiple Background Images</strong></h3>
<p>You can specify multiple background images in a single background property.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"barn.jpg"</span>), <span class="hljs-built_in">url</span>(<span class="hljs-string">"stars.jpg"</span>), <span class="hljs-built_in">linear-gradient</span>(rgba(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">255</span>, <span class="hljs-number">0.5</span>), <span class="hljs-built_in">rgba</span>(<span class="hljs-number">255</span>, <span class="hljs-number">255</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0.5</span>));
}
</code></pre>
<p>The first image (or gradient) specified is the uppermost, the second comes after, and so on. If one of the elements is not correct due to its URL or its syntax, the whole line will be ignored by the browser.</p>
<h3 id="heading-some-basic-background-properties-of-css"><strong>Some Basic Background Properties of CSS</strong></h3>
<p>The CSS background properties are used to define the background effects for elements.</p>
<p>CSS background properties: background-color, background-image, background-repeat, background-attachment, background-position</p>
<h2 id="heading-css-breakpoint-example">CSS Breakpoint Example</h2>
<p>A CSS Breakpoint is a specific point in which a website’s layout changes, based on a <a target="_blank" href="https://guide.freecodecamp.org/css/css3-media-queries">Media Query</a> becoming active.</p>
<p>Generally, you specify a breakpoint when you want to re-adapt the website’s layout to the browser viewport’s size; mostly, to the viewport’s width.</p>
<p>For example, if your website content looks great on a narrow viewport (like on a smart-phone browser), but it starts to look bad on bigger screens (e.g. maybe the fonts’ size are too small and difficult to read), then you might want to introduce a new breakpoint for bigger screens that makes the fonts bigger:</p>
<p>CSS Breakpoints can be considered to be the heart of responsive web design, because they define how the content behaves or is arranged at a different device width/scale. This allows you to show the best possible layout to the user.</p>
<p><img src="https://getflywheel.com/wp-content/uploads/2018/02/css-breakpoints-layouts-01.jpg" alt="Example" width="662" height="371" loading="lazy"></p>
<h2 id="heading-setting-break-points"><strong>Setting Break Points</strong></h2>
<p>Breakpoints are broadly set on the basis of either of the following:</p>
<ul>
<li>Breakpoints based on device width</li>
<li>Breakpoints based on content</li>
</ul>
<h3 id="heading-breakpoints-based-on-device-width"><strong>Breakpoints based on device width</strong></h3>
<p>It’s quite apparent that all of our devices don't have same screen widths/sizes. It is now a design decision to include a set of particular devices and code the CSS rules accordingly. </p>
<p>We already have enough devices to worry about, and when a new one comes out with a different width, going back to your CSS and adding a new breakpoint all over again is time-consuming.</p>
<p>Here’s an example:</p>
<pre><code class="lang-text">/* ----------- iPhone 6, 6S, 7 and 8 ----------- */

/* Portrait */

@media only screen

and (min-device-width: 375px)

and (max-device-width: 667px)

and (-webkit-min-device-pixel-ratio: 2)

and (orientation: portrait) {

}

/* Landscape */

@media only screen

and (min-device-width: 375px)

and (max-device-width: 667px)

and (-webkit-min-device-pixel-ratio: 2)

and (orientation: landscape) {

}

/* ----------- Google Pixel ----------- */

/* Portrait */

@media screen

and (device-width: 360px)

and (device-height: 640px)

and (-webkit-device-pixel-ratio: 3)

and (orientation: portrait) {

}

/* Landscape */

@media screen

and (device-width: 360px)

and (device-height: 640px)

and (-webkit-device-pixel-ratio: 3)

and (orientation: landscape) {

}
</code></pre>
<p>With this approach, you will end up having a huge list of media queries.</p>
<h3 id="heading-breakpoints-based-on-content"><strong>Breakpoints based on Content</strong></h3>
<p>This is the preferred choice while making or writing the breakpoint rules. Because it is easier to adjust your content according a particular layout only when it requires a change.</p>
<pre><code class="lang-text">@media only screen (min-width: 768px){
...
}
</code></pre>
<p>This breakpoint means the CSS will apply when the device width is 768px and above.</p>
<h4 id="heading-you-can-also-set-a-range-with-breakpoints-so-the-css-will-only-apply-within-those-limits"><strong>You can also set a range with breakpoints, so the CSS will only apply within those limits.</strong></h4>
<pre><code class="lang-text">@media only screen and (min-width: 768px) and (max-width: 959px){

...

}
</code></pre>
<p><strong>Note</strong> Always try to create breakpoints based on your own content, not devices. Break them to a logical width rather than a random width and keep them to a manageable number, so modifying remains simple and clear.</p>
<p><strong>CSS breakpoints</strong> are useful when you want to update styles based on the screen size. For example, from a device measuring 1200px width and above, use the <code>font-size: 20px;</code>, or else use the <code>font-size: 16px;</code>.</p>
<p>What we have started with is from devices greater than 1200px, a common laptop screen’s width. You may also have noticed that we mentioned ‘greater than’, meaning that we are in a way using something like an ’<strong>if-then</strong>’ statement.</p>
<p>Let’s turn it into CSS code:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.text1</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">16px</span>;
}
<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">1200px</span>) {
    <span class="hljs-selector-class">.text1</span> {
        <span class="hljs-attribute">font-size</span>: <span class="hljs-number">20px</span>;
    }
}
</code></pre>
<p><strong>For our convenience</strong>, we write down the <code>.text1</code> basic styling first… then afterwards we will specify the <code>@media</code> rules.</p>
<p><strong>Tip</strong>: you may see on a common CSS Framework called ‘Bootstrap’, that they have adopted <strong>‘min-width’ and up</strong> in their Bootstrap v4.0, as compared to their old Bootstrap v3.0 using <strong>‘max-width’ and down</strong>. This is only a <strong>preference</strong>, and there is nothing wrong with saying ’<em>this</em> size and less than’ versus ’<em>this</em> size and greater than’.</p>
<p>It is perfectly fine to use <code>@media (max-width) {}</code> . Here is an example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.text1</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">20px</span>;
}
<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">1199px</span>) {
    <span class="hljs-selector-tag">font-size</span>: 16<span class="hljs-selector-tag">px</span>;
}
</code></pre>
<pre><code class="lang-css">// <span class="hljs-selector-tag">Normal</span>, <span class="hljs-selector-tag">basic</span> <span class="hljs-selector-tag">styles</span>
// <span class="hljs-selector-tag">that</span> <span class="hljs-selector-tag">look</span> <span class="hljs-selector-tag">great</span> <span class="hljs-selector-tag">on</span> <span class="hljs-selector-tag">small</span> <span class="hljs-selector-tag">screens</span>
// <span class="hljs-selector-tag">but</span> <span class="hljs-selector-tag">not</span> <span class="hljs-selector-tag">on</span> <span class="hljs-selector-tag">bigger</span> <span class="hljs-selector-tag">screens</span>
<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">16px</span>;
}

// <span class="hljs-selector-tag">Define</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">new</span> <span class="hljs-selector-tag">breakpoint</span>, <span class="hljs-selector-tag">with</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">media</span> <span class="hljs-selector-tag">query</span>.
// <span class="hljs-selector-tag">In</span> <span class="hljs-selector-tag">this</span> <span class="hljs-selector-tag">case</span>, <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">when</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">viewport</span>'<span class="hljs-selector-tag">s</span> <span class="hljs-selector-tag">width</span>
// <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">least</span> 512<span class="hljs-selector-tag">px</span> <span class="hljs-selector-tag">wide</span>.
<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">512px</span>) {
    <span class="hljs-selector-tag">body</span> {
        <span class="hljs-attribute">font-size</span>: <span class="hljs-number">20px</span>;
    }
}
</code></pre>
<p>Breakpoints that are based on content as opposed to device are less complicated. Here’s a simple snippet that triggers when the device’s width is upward of <code>code 700px</code>, roughly smart-phone screen sized</p>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> <span class="hljs-keyword">only</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">700px</span>) {
  <span class="hljs-selector-tag">something</span> {
    <span class="hljs-attribute">something</span>: something;
  }
}
</code></pre>
<p>You can also set a minimum and maximum width, which lets you experiment with different ranges. This one roughly triggers between smart-phone and larger desktop and monitor sizes:</p>
<pre><code class="lang-code">@media only screen and (min-width: 700px) and (max-width: 1500px) {
  something {
    something: something;
  }
}
</code></pre>
<h2 id="heading-css-color-example">CSS Color Example</h2>
<h3 id="heading-colors">Colors</h3>
<p>CSS Colors is a CSS module that deals with colors, color types, color blending, and opacity. Not all CSS properties that take a as a value are part of this module, but they do depend upon it. </p>
<p>In CSS, you can change the color of almost any element in your HTML page. Properties like <code>background-color</code>, <code>color</code>, and <code>border-color</code> set the color of those elements.</p>
<p>CSS supports color names, hexadecimal, and RGB colors. In addition to the introduction of the <code>opacity</code> declaration, colors in CSS3 can now be specified using color names, or RGB, HEX, HSL, RGBA, HSLA values.</p>
<p>HTML supports 140 standard <a target="_blank" href="https://www.w3schools.com/colors/colors_names.asp">color names</a>.</p>
<h3 id="heading-rgba"><strong>RGB(A)</strong></h3>
<p>RGB stands for “Red, Green, Blue”. An RGB value is a combination of intensity values for red, green, and blue. Each is between 0 (black) and 255 (full intensity). RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color. The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).</p>
<p>An RGB color value is specified with: rgb(red, green, blue). An RGBA color value is similar, with the alpha value in last position: rgba(red, green, blue, alpha).</p>
<h3 id="heading-hsla"><strong>HSL(A)</strong></h3>
<p>HSL stands for “Hue, Saturation and Lightness”. Hue is a degree on the color wheel (from 0 to 360): 0 (or 360) is red, 120 is green, 240 is blue. Saturation is a percentage value: 100% is the full color. Lightness is also a percentage; 0% is dark (black) and 100% is white. </p>
<p>HSLA color values are an extension of HSL color values with an alpha channel - which specifies the opacity for a color.</p>
<p>An HSL color value is specified with: hsl(hue, saturation, lightness). An HSLA color value is similar, with the alpha value in last position: hsla(hue, saturation, lightness, alpha).</p>
<h3 id="heading-cmyk"><strong>CMYK</strong></h3>
<p>CMYK colors are a combination of CYAN, MAGENTA, YELLOW , and BLACK. Computer screens display colors using RGB color values. Printers often present colors using CMYK color values. CMYK is not supported in HTML, but it is suggested as a new standard in CSS4.</p>
<p>Example colors: CMYK Red: cmyk(0%, 100%, 100%, 0%), CMYK Green: cmyk(100%, 0%, 100%, 0%), or CMYK Blue: cmyk(100%, 100%, 0%, 0%).</p>
<h3 id="heading-hexcodes"><strong>Hexcodes</strong></h3>
<p>Hexcode, short for hexadecimal code, is a way to express a color value to your computer. It is named this way because 16 unique symbols can be used as values. In this case, the numbers 0 to 9 and letters a to f are used.</p>
<p>Hex codes are expressed in this format: #000000, which would be the color black in this instance. Six characters are used in each hexcode, using any of the 16 characters mentioned previously. These six characters are divided into three pairs of two.</p>
<p>These three pairs each express a value for the amount of red, green and blue in a particular color. Taking the hexcode color #AA11BB, AA is the amount of red, 11 the amount of green, and BB the amount of blue. 0 is the lowest value of a color while f is the highest value.</p>
<p>Hex codes are case insensitive, meaning that #FFFFFF and #ffffff would be the same color: white.</p>
<p>Additionally, there are 16,777,216 possible color combinations using hexcode.</p>
<h3 id="heading-opacity"><strong>Opacity</strong></h3>
<p>The CSS3 opacity property sets the opacity for the whole element (both background color and text will be opaque/transparent). Unlike alpha values specified with rgba and hsla, opacity is inherited by child elements.</p>
<p>The opacity property value must be a number between 0.0 (fully transparent) and 1.0 (fully opaque).</p>
<h4 id="heading-examples"><strong>Examples</strong></h4>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hello Moto<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-color</span>: green;
  <span class="hljs-attribute">color</span>: white;
}
</code></pre>
<p>In the above example, the <code>background-color: green</code> turns the <code>&lt;body&gt;</code> element green. This turns the whole web page green. The <code>&lt;p&gt;</code> elements are all white after <code>color: white</code> too. You can use named colors, like <code>green</code>, <code>blue</code>, <code>yellow</code>, <code>red</code>, <code>purple</code>, and many others. But for custom colors, you can use hex codes (<code>#147ACC</code>), RGB values (<code>rgb(20, 122, 204)</code>), and even HSL values (<code>hsl(145, 59%, 30%)</code>).</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">244</span>, <span class="hljs-number">145</span>, <span class="hljs-number">14</span>, <span class="hljs-number">0.80</span>); // bright orange
}

<span class="hljs-selector-tag">h2</span> {
 <span class="hljs-attribute">color</span>: <span class="hljs-number">#FA8072</span>; //salmon 
}
</code></pre>
<p>You can also add an alpha value, or transparency to colors. Transparency allows text to be overlaid on an image and still have the image partially viewable through the text, or can be used to change the shade of the colour if no other elements are in front or behind the text. Use <code>rgba()</code> or <code>hsla()</code> and fill in your color values. The alpha value goes last and is a percent converted to a decimal. (For example, 20% is 0.2, 75% is 0.75, etc.)</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-built_in">hsl</span>(<span class="hljs-number">184</span>, <span class="hljs-number">87%</span>, <span class="hljs-number">94%</span>); // bright blue
}
</code></pre>
<p>Above shows paragraphs styled bright orange and 20% transparent, h2 elements a salmon pink, and the body’s background bright blue.</p>
<p>To get custom colors to use in CSS, you might find a color picker helpful. Some text editors have built-in color pickers, like Visual Studio Code. If you search “color picker” on Google or DuckDuckGo, you will get a color picker that you can use. Google Chrome and Firefox also have color picker add-ons that you can install. Adobe Color CC not only helps you pick a color, but will also help you pick out a color scheme for your web page! </p>
<p>It’s a good idea to check that you have enough contrast between your text and background colors by using a tool like WebAIM’s Color Contrast Checker.</p>
<h2 id="heading-colors-in-css-example">Colors in CSS Example</h2>
<p>Colors in CSS are used to colorize elements in our web-pages. There are many ways to assign colors to elements. You can use the actual names for the colors, their RGB values or the Hexadecimal values. In CSS3 the hsl (hue-saturation-lightness) has been added to the specification.</p>
<h3 id="heading-color-names"><strong>Color Names</strong></h3>
<p>Currently there are 140 color names supported in HTML, which can be assigned in CSS rules by just typing their name. For example:</p>
<h3 id="heading-syntax"><strong>Syntax</strong></h3>
<pre><code class="lang-text">p {
  color: green;
}
</code></pre>
<p>This rule changes all the font color for all </p><p> elements to green.<br>For the full 140 color list see here: <a target="_blank" href="https://www.w3schools.com/colors/colors_names.asp">https://www.w3schools.com/colors/colors_names.asp</a></p>
<h3 id="heading-rgb-values"><strong>RGB values</strong></h3>
<p>RGB stands for “Red”, “Green” and “Blue” and we can also assign colors by typing their RGB values in our rules. An RGB value would look like this: rgb(255,0,0), where each number defines how much of each color will be in the final mix.</p>
<p>The values range from 0 to 255, and in our example we see that only the first value is 255 while the other two are set to 0. That means that there is only red in our value and the respective element will be colored red. An RGB value of (0, 0, 0) would give black and a value of (255, 255, 255) would give white.</p>
<p>It is impossible to try to memorize each color code, and for that reason there are numerous tools online for picking the colors you want for your projects. For example: <a target="_blank" href="https://www.w3schools.com/colors/colors_picker.asp">https://www.w3schools.com/colors/colors_picker.asp</a> or <a target="_blank" href="http://htmlcolorcodes.com/color-picker/">http://htmlcolorcodes.com/color-picker/</a>.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgb</span>(<span class="hljs-number">0</span>, <span class="hljs-number">255</span>, <span class="hljs-number">0</span>);
}
</code></pre>
<p>This rule changes the font color of all p elements to green, just like above.</p>
<h3 id="heading-hexadecimal-values"><strong>Hexadecimal Values</strong></h3>
<p>Hexadecimal values are yet another way to define colors in CSS and they work quite similarly to RGB values.</p>
<p>A random hex code would like this: <code>#29432b</code>, where the first two characters after the hash stand for the amount of RED in the mix, the second two stand for the amount of Green, and the last two stand for the amount of Blue.</p>
<p>The values of <code>#000000</code> and <code>#ffffff</code> stand for black and white respectively.<br>You can find the specific Hexadecimal colors you require by using the same tools mentioned for the RGB values.</p>
<h3 id="heading-syntax-1"><strong>Syntax</strong></h3>
<pre><code class="lang-text">p {
  color: #00fe00;
}
</code></pre>
<p>This rule again changes the font color of all p elements to green.</p>
<h3 id="heading-hsl"><strong>HSL</strong></h3>
<p>HSL has three values. The first one is <strong>Hue</strong>, which is measured in degrees. So 0 (or 360) represents the color red, at 120 it is green, and 240 is blue. </p>
<p>The second one is <strong>Saturation</strong> which has a percentage value with a range from 0 to 100%. </p>
<p>And the third one is <strong>Lightness</strong> which also has a percentage value with a range from 0 to 100%. 0% is dark black, 50% average, 100% is white.</p>
<h3 id="heading-syntax-2"><strong>Syntax</strong></h3>
<pre><code class="lang-text">p {
  color: hsl(0, 100%, 50%);
}
</code></pre>
<h3 id="heading-output"><strong>Output</strong></h3>
<p><a target="_blank" href="https://jsfiddle.net/qcw2n145/">JSfiddle</a></p>
<h3 id="heading-why-use-rgb-or-hex-values"><strong>Why use RGB or HEX values?</strong></h3>
<p>Color names take only 140 values, while RGB and HEX values have 16,777,216 possible combinations. So if you want your projects to look exactly how you have envisioned them, you should use the two latter options and keep the color names' values for mock-ups and testing purposes.</p>
<h3 id="heading-the-currentcolor-keyword">The currentColor Keyword</h3>
<p>The currentColor keyword, as the name suggests, is a valid color value in CSS. This represents the value of the specific element’s <code>color</code> property. This lets you use the <code>color</code> property’s value for properties that do not receive it by default.</p>
<p>For example, if we declare each <code>div</code> to have a 3px border of color <code>currentColor</code>, which means that each <code>div</code>’s border will be colored with the same value of its <code>color</code> property<a target="_blank" href="http://jsfiddle.net/tjkp0cm3/">:</a></p>
<pre><code class="lang-css"><span class="hljs-selector-tag">div</span>{
  <span class="hljs-comment">/* The currentColor keyword for the color value, which means that the border will have the value of the respective div's color property */</span>
  <span class="hljs-attribute">border</span>: <span class="hljs-number">3px</span> solid currentColor;
}

<span class="hljs-comment">/* This div will have green borders, because its color value is green. */</span>
<span class="hljs-selector-id">#div1</span>{
  <span class="hljs-attribute">color</span>: green;
}

<span class="hljs-comment">/* This div will have blue borders, because its color value is blue. */</span>
<span class="hljs-selector-id">#div2</span>{
  <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<h3 id="heading-practical-application-with-an-svg"><strong>Practical Application with an SVG</strong></h3>
<p>Here’s a very common example on the web – a button with an SVG icon and text in it. The color of the border, text and icons change on hovering over the button. The below image depicts the initial and the hovered states of the button in order.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/button_variations.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Icon fonts could also be used for this purpose, but there are various advantages of inline SVG over icon fonts, and this may make SVGs the choice for many developers. Quoting <a target="_blank" href="https://css-tricks.com/icon-fonts-vs-svg/">CSS-Tricks</a>,</p>
<blockquote>
<p>It can be frustrating to position a font icon. The icons are inserted via pseudo element, and it depends on <code>line-height</code>, <code>vertical-align</code>, <code>letter-spacing</code>, <code>word-spacing</code>, how the font glyph is designed (does it naturally have space around it? does it have kerning information?). Then the pseudo elements <code>display</code> type affects if those properties have an effect or not. SVG just is the size that it is.  </p>
<p>To sum it up, it can at times be frustrating to use font icons with text.</p>
</blockquote>
<p>We could use this code of ours to achieve the desired behavior:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">button</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#016898</span>;
}

<span class="hljs-selector-class">.emailIcon</span> {
  <span class="hljs-attribute">fill</span>: <span class="hljs-number">#016898</span>;
}

<span class="hljs-selector-tag">button</span><span class="hljs-selector-pseudo">:hover</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#19B5FE</span>;
}

<span class="hljs-selector-tag">button</span><span class="hljs-selector-pseudo">:hover</span> <span class="hljs-selector-class">.emailIcon</span> {
  <span class="hljs-attribute">fill</span>: <span class="hljs-number">#19B5FE</span>;
}
</code></pre>
<p>Now, instead of changing the SVG’s <code>fill</code> color on hover explicitly, we can set the fill to <code>currentColor</code>. This automatically changes the color of the SVG to the value of the <code>color</code> property of the button. We now just need to change the <code>color</code> property of the button. This makes the CSS code shorter and smarter:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.emailIcon</span> {
  <span class="hljs-attribute">fill</span>: currentColor;
}

<span class="hljs-selector-tag">button</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#016898</span>;
}

<span class="hljs-selector-tag">button</span><span class="hljs-selector-pseudo">:hover</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#19B5FE</span>;
}
</code></pre>
<p>Check out the live example at <a target="_blank" href="https://repl.it/NNt9/2">https://repl.it/NNt9/2</a>.</p>
<h2 id="heading-css3-media-queries-example"><strong>CSS3 Media Queries Example</strong></h2>
<p>Media Queries allow you to have different styles for different devices/screen sizes. Their introduction in CSS3 has greatly eased the building of responsive webpages.</p>
<p>The best approach when designing a responsive website is to think mobile first; meaning that you create your page starting with the design and content of the mobile version. </p>
<p>You may think that with some scalable sizes ( %, vw or vh ), your page will adapt perfectly to any device. But it will not. Maybe for some very basic design, but certainly not for more common or complex pages!</p>
<p>When designing your page for smaller devices, you will focus on the main content. On a bigger screen, you will have to readapt some font-sizes, margins, paddings and so on in order to keep your site comfortable and readable. But you will also want/need to add more content, the bits you did not judge fundamental, and fill in the space created by the screen size.</p>
<p>The thought process should be:</p>
<ol>
<li>Which content to show?</li>
<li>How to layout?</li>
<li>Size?</li>
</ol>
<h3 id="heading-the-basic-syntax"><strong>The basic syntax</strong></h3>
<pre><code class="lang-css">    <span class="hljs-keyword">@media</span> <span class="hljs-keyword">only</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">768px</span>) {
      <span class="hljs-selector-tag">p</span> {<span class="hljs-attribute">padding</span>: <span class="hljs-number">30px</span>;}
    }
</code></pre>
<p>The <code>p</code> tag will have a padding of 30px as soon as the screen reaches min 768px width.</p>
<h3 id="heading-the-and-syntax"><strong>The AND syntax</strong></h3>
<pre><code class="lang-css">  <span class="hljs-keyword">@media</span> <span class="hljs-keyword">only</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">min-height:</span> <span class="hljs-number">768px</span>) <span class="hljs-keyword">and</span> (<span class="hljs-attribute">orientation:</span> landscape) {
    <span class="hljs-selector-tag">p</span> {<span class="hljs-attribute">padding</span>: <span class="hljs-number">30px</span>;}
  }
</code></pre>
<p>The <code>p</code> tag will have a padding of 30px as soon as the screen reaches min 768px height and its orientation is landscape.</p>
<h3 id="heading-the-or-syntax"><strong>The OR syntax</strong></h3>
<pre><code class="lang-css">    <span class="hljs-keyword">@media</span> <span class="hljs-keyword">only</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">768px</span>), (<span class="hljs-attribute">min-resolution:</span> <span class="hljs-number">150dpi</span>) {
      <span class="hljs-selector-tag">p</span> {<span class="hljs-attribute">padding</span>: <span class="hljs-number">30px</span>;}
    }
</code></pre>
<p>The <code>p</code> tag will have a padding of 30px as soon as the screen reaches min 768px width or its resolution reaches min 150dpi.</p>
<h2 id="heading-css-fonts-example"><strong>CSS Fonts Example</strong></h2>
<p>The different CSS font properties define the size, weight, style, line height, and font family / typeface of text on the page.</p>
<h3 id="heading-font-family"><strong>Font family</strong></h3>
<p>The font family or typeface of text is set by using the <code>font-family</code> property.</p>
<p>This property works will a fallback system – if your browser doesn't support the first font, it will try each of the following fonts until it finds one that it supports. If the name of the font is longer than one word, it must be surrounded by quotes. For example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
    <span class="hljs-attribute">font-family</span>: <span class="hljs-string">"Times New Roman"</span>, Times, serif;   
}
</code></pre>
<p>Times New Roman is made up of three words and must be surrounded by quotes. Meanwhile, serif is just one word, so it doesn't need quotation marks.</p>
<p>The last item in the list should always be a generic font family name such as serif, sans-serif, monospace, cursive, fantasy, system-ui.</p>
<h3 id="heading-font-style"><strong>Font style</strong></h3>
<p>The <code>font-style</code> property can be used to make text italic or oblique.</p>
<p>There are three possible values for this property:</p>
<ul>
<li>normal - Text is shown normally</li>
<li>italic - Text is shown in <em>italic</em></li>
<li>oblique - Text is shown leaning</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-class">.normal</span> {
    <span class="hljs-attribute">font-style</span>: normal;
}

<span class="hljs-selector-class">.italic</span> {
    <span class="hljs-attribute">font-style</span>: italic;
}

<span class="hljs-selector-class">.oblique</span> {
    <span class="hljs-attribute">font-style</span>: oblique;
}
</code></pre>
<h3 id="heading-font-size"><strong>Font size</strong></h3>
<p>Use the <code>font-size</code> property to adjust the size of the text. The default size of text is <code>16px</code> in most browsers.</p>
<p>Here are the most commonly used font size values:</p>
<ul>
<li><code>px</code> (pixels)</li>
<li><code>em</code> - <code>1em</code> – the font size of the parent</li>
<li><code>rem</code> – the font size of the root element</li>
<li><code>%</code> - percentages</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-class">.with-pixels</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">14px</span>;
}

<span class="hljs-selector-class">.with-ems</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">0.875em</span>;
}

<span class="hljs-selector-class">.with-absolute</span> {
    <span class="hljs-attribute">font-size</span>: large;
}

<span class="hljs-selector-class">.with-percentage</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">80%</span>;
}
</code></pre>
<h3 id="heading-font-weight"><strong>Font weight</strong></h3>
<p>The <code>font-weight</code> property adjusts the weight of text. This property accepts keyword values like <code>bold</code> or <code>normal</code>, and numeric keyword values such as <code>400</code> and <code>700</code>.</p>
<p>Here are some common keyword and numeric keyword values:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Keyword Values</td><td>Numeric Keyword Values</td></tr>
</thead>
<tbody>
<tr>
<td>100</td><td><code>thin</code></td></tr>
<tr>
<td>300</td><td><code>light</code></td></tr>
<tr>
<td>400</td><td><code>normal</code></td></tr>
<tr>
<td>500</td><td><code>medium</code></td></tr>
<tr>
<td>700</td><td><code>bold</code></td></tr>
<tr>
<td>900</td><td><code>black</code></td></tr>
</tbody>
</table>
</div><p>The default font weight is <code>400</code> or <code>normal</code>.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
   <span class="hljs-attribute">font-weight</span>: bold
}
</code></pre>
<p><strong>Note:</strong> Not all keyword or numeric keyword values are available for every font family. For example, if you are loading a font family from Google Fonts, you need to select all the font weights you want to use.</p>
<h2 id="heading-css-text-align-example"><strong>CSS Text Align Example</strong></h2>
<p>This CSS property describes the horizontal alignment of inline content in its parent block element. <code>text-align</code> does not control the alignment of block elements, it affects only their inline content.</p>
<h3 id="heading-values"><strong>Values:</strong></h3>
<p>The <code>text-align</code> property is specified as a single keyword chosen from the list of values below:</p>
<p><code>text-align: left;</code> aligns the text to the left</p>
<p><code>text-align: right;</code> aligns the text to the right</p>
<p><code>text-align: center;</code> aligns the text to the center</p>
<p><code>text-align: justify;</code> makes the lines the same width</p>
<p><code>text-align: justify-all;</code> makes the lines the same width, including the last one</p>
<p><code>text-align: start;</code> aligns the last line at the beginning of the line</p>
<p><code>text-align: end;</code> aligns the last line at the end of the line</p>
<p><code>text-align: match-parent;</code> calculates the value's start and end to the parent’s direction and replaced by the appropriate left or right value.</p>
<p><strong>Block Alignment Values (non-standard syntax)</strong>:</p>
<p><code>text-align: -moz-center;</code></p>
<p><code>text-align: -webkit-center;</code></p>
<p><strong>Global Values</strong>:</p>
<p><code>text-align: inherit;</code> inherits from its parent element</p>
<p><code>text-align: initial;</code> default value</p>
<p><code>text-align: unset;</code> applies either the inherit or the initial value, depending on the default properties of the element</p>
<h2 id="heading-css-box-model-example"><strong>CSS Box Model Example</strong></h2>
<p>Understanding the CSS Box Model is crucial to being able to correctly layout a web page.</p>
<p>When a browser renders (draws) a web page each element, for example, a piece of text or an image is drawn as a rectangular box following the rules of the CSS Box Model.</p>
<p>At the center of the box is the content itself, which takes up a certain height and width. This region is known as the <strong>Content Area</strong>. The size of the content area can be automatically determined, or you can explicitly set the size of height and width (see note below regarding <code>box-sizing</code>).</p>
<p><img src="https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/content%20area.jpg" alt="Content Area Image" width="600" height="400" loading="lazy"></p>
<p>Around the Content Area, this is a region known as <strong>Padding Area</strong>. The size of the padding can be the same all around (set with <code>padding</code>), or you can set individually for the top, right, bottom and left paddings (with <code>padding-top</code>, <code>padding-right</code>, <code>padding-bottom</code> and <code>padding-left</code>).</p>
<p><img src="https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/padding%20area.jpg" alt="Padding Area Image" width="600" height="400" loading="lazy"></p>
<p>Next, there is a <strong>Border Area</strong>. This creates a border around the element and its padding. You can set thickness (<code>border-width</code>), color (<code>border-color</code>), and style (<code>border-style</code>) of the border. Style options include <code>none</code> (no border), <code>solid</code>, <code>dashed</code>, <code>dotted</code> and several others. </p>
<p>Additionally, you can set the borders on the 4 sides individually; for example, the top border with <code>border-top-width</code>, <code>border-top-color</code> and <code>border-top-style</code> for its thickness, color and style. (See note below regarding <code>box-sizing</code>.)</p>
<p><img src="https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/border%20area.jpg" alt="Border Area Image" width="600" height="400" loading="lazy"></p>
<p>Finally, there is the <strong>Margin Area</strong>. This creates clear space around the element, padding, and border. Again you can individually set the top, right, bottom and left margins (with <code>margin-top</code>, <code>margin-right</code>, <code>margin-bottom</code> and <code>margin-left</code>). Under certain circumstances, margin collapsing occurs and the margins between adjacent elements may be shared.</p>
<p><img src="https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/margin%20area2.jpg" alt="Margin Area Image" width="600" height="400" loading="lazy"></p>
<p><strong><code>box-sizing</code> Property</strong>: The default for this property is <code>content-box</code>. If you use the default, then the box model will allow the author to specify the size of the content area. However, it is possible to use these to instead specify the size of the border area. This is done by changing <code>box-sizing</code> property to <code>border-box</code>. This can sometimes make layouts easier. You can set the <code>box-sizing</code> property per element as desired.</p>
<h2 id="heading-css-cursors"><strong>CSS Cursors</strong></h2>
<p>The cursor property specifies the type of cursor to be displayed when you hover over an element. It has 36 possible values:</p>
<pre><code class="lang-css">    <span class="hljs-selector-class">.auto</span>            { <span class="hljs-attribute">cursor</span>: auto; }
    <span class="hljs-selector-class">.default</span>         { <span class="hljs-attribute">cursor</span>: default; }
    <span class="hljs-selector-class">.none</span>            { <span class="hljs-attribute">cursor</span>: none; }
    <span class="hljs-selector-class">.context-menu</span>    { <span class="hljs-attribute">cursor</span>: context-menu; }
    <span class="hljs-selector-class">.help</span>            { <span class="hljs-attribute">cursor</span>: help; }
    <span class="hljs-selector-class">.pointer</span>         { <span class="hljs-attribute">cursor</span>: pointer; }
    <span class="hljs-selector-class">.progress</span>        { <span class="hljs-attribute">cursor</span>: progress; }
    <span class="hljs-selector-class">.wait</span>            { <span class="hljs-attribute">cursor</span>: wait; }
    <span class="hljs-selector-class">.cell</span>            { <span class="hljs-attribute">cursor</span>: cell; }
    <span class="hljs-selector-class">.crosshair</span>       { <span class="hljs-attribute">cursor</span>: crosshair; }
    <span class="hljs-selector-class">.text</span>            { <span class="hljs-attribute">cursor</span>: text; }
    <span class="hljs-selector-class">.vertical-text</span>   { <span class="hljs-attribute">cursor</span>: vertical-text; }
    <span class="hljs-selector-class">.alias</span>           { <span class="hljs-attribute">cursor</span>: alias; }
    <span class="hljs-selector-class">.copy</span>            { <span class="hljs-attribute">cursor</span>: copy; }
    <span class="hljs-selector-class">.move</span>            { <span class="hljs-attribute">cursor</span>: move; }
    <span class="hljs-selector-class">.no-drop</span>         { <span class="hljs-attribute">cursor</span>: no-drop; }
    <span class="hljs-selector-class">.not-allowed</span>     { <span class="hljs-attribute">cursor</span>: not-allowed; }
    <span class="hljs-selector-class">.all-scroll</span>      { <span class="hljs-attribute">cursor</span>: all-scroll; }
    <span class="hljs-selector-class">.col-resize</span>      { <span class="hljs-attribute">cursor</span>: col-resize; }
    <span class="hljs-selector-class">.row-resize</span>      { <span class="hljs-attribute">cursor</span>: row-resize; }
    <span class="hljs-selector-class">.n-resize</span>        { <span class="hljs-attribute">cursor</span>: n-resize; }
    <span class="hljs-selector-class">.e-resize</span>        { <span class="hljs-attribute">cursor</span>: e-resize; }
    <span class="hljs-selector-class">.s-resize</span>        { <span class="hljs-attribute">cursor</span>: s-resize; }
    <span class="hljs-selector-class">.w-resize</span>        { <span class="hljs-attribute">cursor</span>: w-resize; }
    <span class="hljs-selector-class">.ns-resize</span>       { <span class="hljs-attribute">cursor</span>: ns-resize; }
    <span class="hljs-selector-class">.ew-resize</span>       { <span class="hljs-attribute">cursor</span>: ew-resize; }
    <span class="hljs-selector-class">.ne-resize</span>       { <span class="hljs-attribute">cursor</span>: ne-resize; }
    <span class="hljs-selector-class">.nw-resize</span>       { <span class="hljs-attribute">cursor</span>: nw-resize; }
    <span class="hljs-selector-class">.se-resize</span>       { <span class="hljs-attribute">cursor</span>: se-resize; }
    <span class="hljs-selector-class">.sw-resize</span>       { <span class="hljs-attribute">cursor</span>: sw-resize; }
    <span class="hljs-selector-class">.nesw-resize</span>     { <span class="hljs-attribute">cursor</span>: nesw-resize; }
    <span class="hljs-selector-class">.nwse-resize</span>     { <span class="hljs-attribute">cursor</span>: nwse-resize; }
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/24_cursor_styles.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can also set an image as the cursor.</p>
<pre><code class="lang-text">.custom-cursor {
  cursor: url(cursor-image.png);
}
</code></pre>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn CSS in this free 6-hour video course ]]>
                </title>
                <description>
                    <![CDATA[ It is important for all web developers to be familiar with CSS, or Cascading Style Sheets. CSS is responsible for the styling and looks of a website. Learn how to use it in this complete 6-hour course for beginners from Jad Khalili. This free video c... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-css-in-this-free-6-hour-video-course/</link>
                <guid isPermaLink="false">66b2041d08bc664c3c097ec9</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Wed, 16 Oct 2019 16:06:51 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/10/css.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>It is important for all web developers to be familiar with CSS, or Cascading Style Sheets. CSS is responsible for the styling and looks of a website. Learn how to use it in this complete 6-hour course for beginners from Jad Khalili.</p>
<p>This free video course covers CSS from the ground up. You will learn everything from basic skills, such as coloring and text, to highly advanced skills, like custom animations.</p>
<p>Here are some of the things you'll learn in this course:</p>
<ul>
<li>how to color text and elements,</li>
<li>how to format sections on a website,</li>
<li>how to change the style and size of text,</li>
<li>how to use CSS to layout elements on a page,</li>
<li>how to use CSS Grid,</li>
<li>how to use CSS Flexbox,</li>
<li>how to animate elements on a page,</li>
<li>how to add transitions to animations,</li>
<li>and more!</li>
</ul>
<p>Watch the full 6-hour course below or <a target="_blank" href="https://youtu.be/1Rs2ND1ryYc">on the freeCodeCamp.org YouTube channel</a>.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/1Rs2ND1ryYc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ A Learning Path for Newbies in WordPress Development ]]>
                </title>
                <description>
                    <![CDATA[ By Ihtisham Zahoor In this information age, one obstacle in learning something new is not where to find the resources. It’s from where to start and make sense of all the resources available online these days. This holds especially true in web develop... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learning-path-for-newbies-in-wordpress-development-a283981adf53/</link>
                <guid isPermaLink="false">66d45f32b6b7f664236cbdcc</guid>
                
                    <category>
                        <![CDATA[ Bootstrap ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML5 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ jQuery ]]>
                    </category>
                
                    <category>
                        <![CDATA[ js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ PHP ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Sass ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ WordPress ]]>
                    </category>
                
                    <category>
                        <![CDATA[ wordpress plugins ]]>
                    </category>
                
                    <category>
                        <![CDATA[ WordPress Theme ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 12 Sep 2018 18:46:58 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/0*RlFuY9MLjBJDt1U5" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ihtisham Zahoor</p>
<p>In this information age, one obstacle in learning something new is not where to find the resources. It’s from where to start and make sense of all the resources available online these days. This holds especially true in web development when new tools are popping up overnight.</p>
<p>Back in 2015, since I first decided to learn web development, I have faced challenges of self-doubt and lack of motivation. But the one challenge which drained my energies was not knowing what path to follow.</p>
<p>Considering the initial challenges in this path I have written this piece for technology enthusiasts who want to get their hands dirty in web development. Especially WordPress development. All in the hope you are going to spend your time building something cool than getting into this never-ending vicious cycle of learning one tool to another.</p>
<h1 id="heading-caution-a-lot-of-learning-in-this-path"><strong>Caution! A lot of learning in this path</strong></h1>
<p>I am a WordPress developer (although my impostor syndrome tells me otherwise). I can share my experience only related to WordPress. But before diving into details, let’s examine a Q/A session first.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/NXiCcxwi7e3plLZMWr3KAfpSuCMA1KA5ODNe" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now, is the answer mean? Maybe. Is it true? Absolutely! WordPress and Web Development, in general, are as serious and demanding as any profession. So be ready for…</p>
<ul>
<li>Lifetime of Learning</li>
<li>Pulling all-nighters occasionally</li>
</ul>
<p>All right, have you read and understood the above points? Great. Now relax as it is not to discourage you or anything. It’s just how the life of a developer is as the ever-changing nature of this field requires.</p>
<p>The good news is there are not many web technologies you have to learn to master the craft of WordPress Development. That being said, give your time to this amazing piece of software, and WordPress will adore you in return.</p>
<p>WordPress will change your life if you let it — Chris Lema</p>
<p>It’s all inspiring and cute, right? It is one of the reasons <a target="_blank" href="https://topher1kenobe.com/">Topher DeRosia</a> (huge props) has provided the <a target="_blank" href="https://heropress.com/">HeroPress</a> platform for WordPressers (yes, this is what we proudly call ourselves). Here WordPressers share regularly their WordPress origin stories with the <a target="_blank" href="https://opensource.org/community">community</a>. Rest assured while reading through the stories you are going to feel adrenaline rush through your body as many of you are going to find yourself related to those stories.</p>
<h1 id="heading-wordpress-for-everyone">WordPress for Everyone!</h1>
<p>WordPress is super easy to use. In fact, anyone without any technical knowledge, can set up and start using WordPress in no time. However, WordPress has a vast ecosystem. I, for one, would categorize WordPress development being carried out in two different domains. I’ll first list those domains below and then I will discuss each one separately.</p>
<ul>
<li>WordPress Site Customization</li>
<li>WordPress Themes/Plugins Development</li>
</ul>
<h1 id="heading-wordpress-site-customization">WordPress Site Customization</h1>
<p>WordPress Site Customization is where all the buzz is about, as it amounts for most of the work done with respect to WordPress usage. Site Customization is that domain where no prior coding knowledge is required.</p>
<p>That is to say, a WordPress power user can easily perform tasks like Theme/Plugin setup and customization using page builders, site debugging, and site maintenance, etc. Moreover, Theme customization is all about customizing or modifying a pre-made theme as per the requirements of your client.</p>
<p>Considering that, and to give you a perspective about the process, you can watch the following short tutorial by Tyler Moore. In his tutorial, he builds a new website by customizing a pre-made theme using the Elementor page builder.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/8AZ8GqW5iak" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h1 id="heading-wordpress-themesplugins-development">WordPress Themes/Plugins Development</h1>
<p>It is where all the fun is for WordPress geeks. We can call it the <em>actual</em> WordPress development, as this domain is all about knowing and getting into the nitty-gritty technical details of programming. It can be as simple as using a few WordPress hooks to modify responses or as complex as building a full-fledge product on WordPress.</p>
<p>So, in case you want to start into this domain, you have to invest more time learning about web technologies involved in WordPress development. Considering that, the rest of this article will discuss all the technologies and a few tips and tricks to get you started in <em>actual</em> WordPress development.</p>
<h1 id="heading-learning-path"><strong>Learning Path</strong></h1>
<p>To get started in your WordPress Development journey, these tools and technologies are what you are going to be working with.</p>
<ol>
<li><p>Say hello and embrace g̵o̵o̵d̵ ̵o̵̵̵l̵̵̵’ HTML5 modules with Semantics and Accessibility concepts. HTML is what gives structure to the site contents.</p>
</li>
<li><p>This quote says it all:</p>
</li>
</ol>
<p>You are the CSS to my HTML — Some Genius</p>
<p>CSS is how HTML is presented in the web browser. Make sure to learn SASS preprocessor as your savior in writing modular CSS once you get a grasp of the basics.</p>
<ol start="3">
<li>The organization behind WordPress has big plans for making JavaScript part of the WordPress Front-end. This officially came from the original author of WordPress.</li>
</ol>
<p>Learn JavaScript, Deeply — Matt Mullenweg</p>
<p>Yes, I know that might be far-fetched for a newbie who is starting out to follow this advice, but keep an eye out for development in this area. Now, this doesn’t mean you have to master JavaScript to work with WordPress. Start with the basics including its hugely popular library jQuery.</p>
<ol start="4">
<li><p>Wouldn’t it be nice if you could get a 1000-step head-start with these three technologies to speed up your development process? Well, that is where front-end frameworks like <a target="_blank" href="http://getbootstrap.com/">Twitter Bootstrap</a> come into play. Explore it and get amazed. Don’t confuse front-end frameworks with JavaScript frameworks. Front-end is used interchangeably with JavaScript libraries and frameworks, which is a whole different path.</p>
</li>
<li><p>PHP is the scripting language that powers WordPress. If you want to dive deep in WordPress, learn PHP head-first with its OOP concepts including MySQL as its back-end database.</p>
</li>
<li><p>In general, when people talk about WordPress Development, it usually means only two segments of WordPress.</p>
</li>
<li><p>WordPress Theme Development, which is developing a presentation (layout) of sites (hence the name “Theme”).</p>
</li>
<li>WordPress Plugin Development, which is to add functionality to WordPress sites</li>
</ol>
<p>For a developer, it is of utmost importance to understand and be comfortable working with both these segments. And to add a tad bit more in your learning journey, get familiar with Internationalization and Localization. You also need to know WordPress Hooks and APIs to name a few.</p>
<p>While developing sites, most of your time is going to be spent in a local development environment and in a code editor. For the sake of complete information in this article, let me point you to an easy-to-setup yet powerful local development environment (<a target="_blank" href="https://local.getflywheel.com/">Local by Flywheel</a>) and lightning-fast code editor (<a target="_blank" href="https://code.visualstudio.com/">Visual Studio Code</a> by Microsoft). Yes, they are both free of cost like WordPress.</p>
<h2 id="heading-workflow"><strong>Workflow</strong></h2>
<p>As your workflow becomes more advanced and complex, it’s important for you to stay sane and keep enjoying life. In that case, you are going to need to streamline your workflow. Try task automation tools like <a target="_blank" href="https://gruntjs.com/">Grunt</a>/<a target="_blank" href="https://gulpjs.com/">Gulp</a> and use a version control system like <a target="_blank" href="https://git-scm.com/">git</a> to keep you from making blunders.</p>
<h2 id="heading-illustration-of-learning-path-guide-published-on-github"><strong>Illustration of Learning Path Guide Published on GitHub</strong></h2>
<p>To make things more clear for you, I have published an illustration of the Learning Path as a step-by-step guide on <a target="_blank" href="https://github.com/ihtishamzahoor/wordpress-learning-path">GitHub</a> which I have provided below.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/BglSkXSPbis8Tkk86z5kuf3VVx4Pt2KNkdfx" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Learn from it, give feedback, improve it to make it better for newbies, and by that means feel free to send PR requests.</p>
<h1 id="heading-resources"><strong>Resources</strong></h1>
<p>In case you are still worried that you are going to need more than a bunch of motivational words to actually start doing meaningful work, maybe you need like a step by step guide — well, worry no more. Follow the <a target="_blank" href="https://developer.wordpress.org/"><strong><em>WordPress WordPress Developer Handbook</em></strong></a> and <a target="_blank" href="https://codex.wordpress.org/"><strong><em>WordPress Developer Codex</em></strong></a> like religion and consider yourself in safe hands.</p>
<p>Moreover, you can receive great help from the <a target="_blank" href="https://wordpress.org/support/"><strong><em>WordPress Support</em></strong></a> forum as well as digging your answers from the Q&amp;A site <a target="_blank" href="https://stackoverflow.com/"><strong><em>Stack Overflow</em></strong></a>, which is immensely popular among the developer community.</p>
<p>Apart, from the official WordPress resources, support forum, and developer-centric Q&amp;A sites. There are a plethora of sites like <a target="_blank" href="https://wpbeginner.com/"><strong><em>WPBeginner</em></strong></a><strong><em>,</em></strong> made possible by the awesome WordPress community, offering WordPress centric free tutorials and guides.</p>
<p><a target="_blank" href="https://www.codexspot.com/category/tutorials/"><strong><em>CodexSpot</em></strong></a> is one such attempt by a bunch of <a target="_blank" href="https://www.codexspot.com/about-us/"><em>WordPress geeks</em></a> including yours truly to give back to the community. <em>CodexSpot</em> is an online platform, focused solely on providing web solutions. Our aim is to provide quality tutorials, DIY guides, and keep you up-to-date with web industry news and trend reports.</p>
<p>We are a huge supporter of free and open-source software initiative and don’t miss any opportunity to evangelize FOSS practices to promote this movement. Besides that, we also offer free web development generators and tools to speed up your development time.</p>
<p>Now, there is one other type of learning resource, which is premium courses. By comparison with free resources, the main benefit of premium ones is the timely support offered by the course instructors for their students. That is to say, the ability to get your queries answered by the very instructors from whom you are learning, hugely benefits you during your learning journey. Furthermore, they stay on top of the latest industry trends.</p>
<p>I have personally learned a great deal from the <a target="_blank" href="https://www.lynda.com/learning-paths/Web/become-a-junior-wordpress-developer"><strong><em>Lynda.com</em></strong></a> (now <em>LinkedIn Learning</em>) courses, highly recommended. I have also found <a target="_blank" href="https://onemonth.com/courses/wordpress"><strong><em>Learn WordPress</em></strong></a> course by <em>Chris Castiglione, a nice beginner-friendly course to start with. So, if you are looking for a premium course on WordPress, you will find any of these courses worth your buck</em>.</p>
<p>At this point, you have the dedication and tons of resources readily available for you to learn everything about WordPress. However, it is equally important that you understand the job market and what the companies seek in candidates applying for the WordPress developer position.</p>
<p><a target="_blank" href="https://www.toptal.com/">Toptal</a>, an exclusive network of the top freelancers in the world, has published a guide for hiring a “<a target="_blank" href="https://www.toptal.com/wordpress#hiring-guide">Great WordPress Developer</a>” which you can read to better align yourself with the most in-demand WordPress skills.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Don’t try to learn everything at once. Start with the basics. Implement what you’ve learned and then build from there. Take note of these following two not hard-and-fast rules for guidance, as these rules will come in handy in your journey.</p>
<ul>
<li><em>Just in Time (JIT) learning</em> is you learn the tool when you need it.</li>
<li><em>80/20 rule of learning</em> is you give 20% of your time to learning and 80% of your time implementing what you have learned already.</li>
</ul>
<p>Now repeat after me:</p>
<p>I learn.<br>I code!<br>I code again!!<br>I code some more!!!<br>I keep coding!!!!!</p>
<p>…and that is how you start in WordPress. Good Luck WordPresser and welcome to the WordPress family!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
