<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: John Palmgren</title>
    <description>The latest articles on DEV Community by John Palmgren (@johnpalmgren).</description>
    <link>https://dev.to/johnpalmgren</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F795454%2F8ea10808-5aac-458c-84c3-d4f593dee385.png</url>
      <title>DEV Community: John Palmgren</title>
      <link>https://dev.to/johnpalmgren</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johnpalmgren"/>
    <language>en</language>
    <item>
      <title>How to Make Buttons Stand Out with CSS</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Thu, 03 Mar 2022 15:21:48 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/how-to-make-buttons-stand-out-with-css-4f7f</link>
      <guid>https://dev.to/johnpalmgren/how-to-make-buttons-stand-out-with-css-4f7f</guid>
      <description>&lt;p&gt;The first thing you’ll notice when you add a button to your website is that you’ve taken a trip back in time to 1999. The default button style is very old-fashioned and I can’t think of a use case where you’d want to keep it as it is. The good news is that there are loads of CSS styles that can make your buttons pop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remove Default
&lt;/h2&gt;

&lt;p&gt;The first thing to do is remove the default buttons styles. It’s one of&lt;br&gt;
those things that you might do 100 times, but you still need to&lt;br&gt;
google every time. The CSS on how to remove the default style is&lt;br&gt;
below.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;font&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;This will turn a button that looks like this&lt;/p&gt;

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

&lt;p&gt;into one that looks like this &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5jot7tqy1iayc7exo19.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5jot7tqy1iayc7exo19.jpg" alt="button with no style"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Color and Size
&lt;/h2&gt;

&lt;p&gt;The next thing to do is to add your own styles. Bold colors with high&lt;br&gt;
contrast text will help the button stand out. You will also probably&lt;br&gt;
want to increase the button’s default size to make it more&lt;br&gt;
prominent and add some padding. A call to action button might look like this.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwgmvozjj8o82cxecdd7j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwgmvozjj8o82cxecdd7j.jpg" alt="button with red background"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Fonts
&lt;/h2&gt;

&lt;p&gt;Fonts can be another great way to make a button look more attractive. I've added the font Oswald from Google Fonts. I like a bold sans-serif font on a button but you should choose whatever you like. Follow the instruction on Google to add the font to your project then insert &lt;code&gt;font-family: "Oswald", sans-serif;&lt;/code&gt; into the button CSS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpojt60mcze45ipcfvutg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpojt60mcze45ipcfvutg.jpg" alt="button with custom font"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Border-radius and Box-shadow
&lt;/h2&gt;

&lt;p&gt;So far the button is standing out a lot more but to make it looks like it seamlessly fits into the webpage it needs a couple more elements. &lt;code&gt;border-radius&lt;/code&gt; and &lt;code&gt;box-shadow&lt;/code&gt;. The border-radius will round the corners of the button. How much you want to do this is up to you. You can just take the sharpness off the edges of the corners or turn it into a full circle. &lt;code&gt;box-shadow&lt;/code&gt; as the name suggests will give your button a shadow, which will give it a cool floating appearance. You can do a lot with &lt;code&gt;box-shadow&lt;/code&gt; so read more about the properties &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow?ref=hackernoon.com" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;Button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.6rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbqxggsv10y9uguh2w2q.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbqxggsv10y9uguh2w2q.jpg" alt="button with border-radius and box shadow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Hover and Active
&lt;/h2&gt;

&lt;p&gt;Now our button is looking pretty good, it’s time to add some&lt;br&gt;
functionality. You can add all sorts of styles with &lt;code&gt;:hover&lt;/code&gt; for when the button is hovered over and &lt;code&gt;:active&lt;/code&gt; for when the button is clicked. Some of the things you might want to do are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;change the box shadow&lt;/li&gt;
&lt;li&gt;change shape&lt;/li&gt;
&lt;li&gt;change color
For our button well change the brightness and box-shadow on hover and add indentation when it's clicked with &lt;code&gt;::active&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;brightness&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;120%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inset&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;



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

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

&lt;p&gt;For some awesome examples of what can be done by manipulating &lt;code&gt;:hover&lt;/code&gt; and &lt;code&gt;:active&lt;/code&gt; check out &lt;a href="https://cssbuttons.io/" rel="noopener noreferrer"&gt;this website&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;::After&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;What other fun things can be done with buttons? You can combine &lt;code&gt;::before&lt;/code&gt; and &lt;code&gt;::after&lt;/code&gt; with &lt;code&gt;:hover&lt;/code&gt; or &lt;code&gt;:active&lt;/code&gt; to add extra content to the button. In the code below I’ve added &lt;code&gt;::after&lt;/code&gt; and &lt;code&gt;:hover&lt;/code&gt; with CSS animation to create an underline when the button is hovered.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.1s&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover::after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

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

&lt;p&gt;Now it might be overkill having all of these effects but it shows you what can be achieved.&lt;/p&gt;

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

&lt;p&gt;There are a couple of important accessibility requirements to bear in mind. Please please please use a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; tag. You can create something that looks and works like a button using &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; but it doesn’t have the same semantic meaning as a button. This means that screen readers won’t know that it is a button. A button should look like a button. This is not just good for&lt;br&gt;
accessibility but for anyone trying to navigate your site. With all the styles you can add it’s important to remember that it should still be obvious that the element is a button. It should look “clickable”. If it’s ambiguous it will cause confusion which is not great for accessibility or UX. Adding some &lt;code&gt;box-shadow&lt;/code&gt; to the button often creates this effect. Make the button easily visible. Much like you want good contrast between text and the background, you also want to give your buttons lots of contrast. It’s also important to show the status of a button. If a button is going to remain depressed after clicking, to show that it is active, consider adding a border or underline so that it can’t be missed. This is important if the button shows the status of something rather than if it’s just to submit a form, for example. Compare: &lt;/p&gt;

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

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

</description>
      <category>css</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>design</category>
    </item>
    <item>
      <title>Is a Web Development Bootcamp Worth it in 2022?</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Thu, 24 Feb 2022 14:31:52 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/is-a-web-development-bootcamp-worth-it-in-2022-1o3f</link>
      <guid>https://dev.to/johnpalmgren/is-a-web-development-bootcamp-worth-it-in-2022-1o3f</guid>
      <description>&lt;h2&gt;
  
  
  What is a Bootcamp?
&lt;/h2&gt;

&lt;p&gt;A Bootcamp is a course that runs over a short period of time -- often around 3 months. It is normally full-time and intensive, with self-study also required (although part-time options are sometimes available). It is taught by industry experts with an emphasis on giving you the skills you need to land a job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Bootcamps
&lt;/h2&gt;

&lt;p&gt;There are lots of different boot camps that exist, all with their pros and cons. If you are considering doing a Bootcamp then research is key. below is a list of some of the types of boot camps that you can take.&lt;/p&gt;

&lt;h3&gt;
  
  
  Commercial
&lt;/h3&gt;

&lt;p&gt;The most common type of Bootcamp is a regular commercial Bootcamp. Normally set up by a group of individual programmers or by a company wishing to deliver a service. There is usually a large upfront cost for this but there is a lot of variation so make sure to do your research.&lt;/p&gt;

&lt;h3&gt;
  
  
  Job Guaranteed
&lt;/h3&gt;

&lt;p&gt;Another increasingly common type of Bootcamp is a job-guaranteed Bootcamp. As the name suggests, they will guarantee that you get a job as a result of completing the course. If you don't get a job within a certain amount of time you will not have to pay for the course. These Bootcamps may be more selective about who they let on the course as they want to make sure everyone has the potential to become employed by the end of it. There are two types of job guaranteed Bootcamps, ones where you need to pay upfront, and will be refunded if you are not able to get a job and ones where you only pay when you get the job. Clearly, there is less risk with the second option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Funded
&lt;/h3&gt;

&lt;p&gt;Depending on where you are in the world there may be other options available to you. In the UK the government has funded many "skills bootcamps" to improve the employability prospects of people needing to change careers.&lt;/p&gt;

&lt;h2&gt;
  
  
  what's the alternative?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Degree
&lt;/h3&gt;

&lt;p&gt;There is always the option of going down the traditional route and getting a degree. This is certainly not essential but is one way to get your foot in the door. The upside to this is that you will be able to enroll in a graduate program after finishing your degree, and some employers will only hire people with a computer science degree. The downside (the big one) is that it costs a lot of money. It also takes a lot of time and may be overkill to get your foot in the door as a web developer. That being said, if it's the kind of thing that would interest you anyway, and you've got the time and money, then this is worth considering.&lt;/p&gt;

&lt;h3&gt;
  
  
  Self-taught
&lt;/h3&gt;

&lt;p&gt;Another popular alternative to going to a Bootcamp is to teach yourself using online resources. There is certainly no shortage of resources, both free and paid. The upside here is that you can get an education in Web Development by spending very little money or even free. The downside is that some employers might not take you as seriously (but if you've got a solid portfolio, that will help). And you lack the format and direction of a formal course. You may also find it harder to make connections with others doing the same thing as you, but there are plenty of opportunities to do so if you look hard enough.&lt;/p&gt;

&lt;p&gt;You can also choose to take a Bootcamp style online course. This may help give you a format of what to study and when, which is one of the hardest parts of self-study, but it will lack the in-person feedback you can get from a Bootcamp or degree.&lt;/p&gt;

&lt;h2&gt;
  
  
  My experience
&lt;/h2&gt;

&lt;p&gt;I spent most of a year learning Python before switching and teaching myself web development for another year. After that, I joined a funded Web Development Skills Bootcamp.&lt;/p&gt;

&lt;p&gt;I have enjoyed the journey of teaching myself. I find the thrill of learning and building new things satisfying in itself. That being said, it can be hard to maintain motivation when you're doing it on your own. It is also hard to decide what to learn when. There's no curriculum to follow and you have to decide for yourself whether to learn Tailwind vs SASS or, React vs Angular, for instance.&lt;/p&gt;

&lt;p&gt;My personal bootcamp experience has been underwhelming. I don't want to put anyone off, and I'm sure this is not a universal experience. It's also worth bearing in mind, as shown above, that there are many different types of Bootcamps. The one I'm on is facilitated by a university and funded by the government as part of the Skills Bootcamp initiative. The program has been put together in a rushed way and there have been some poor staffing choices. There doesn't seem to be the drive to add value in the way I imagine a commercial bootcamp might, where the participants might have paid thousands of pounds to attend. But again, I must stress that this is just one experience and there are many other Bootcamps around.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is it worth it?
&lt;/h2&gt;

&lt;p&gt;There are many things to consider when deciding if a bootcamp will be worth it for you. Asking yourself the below questions can help you decide if it's for you&lt;/p&gt;

&lt;h3&gt;
  
  
  What's the cost?
&lt;/h3&gt;

&lt;p&gt;The question at the front of your mind will probably be the cost. No matter how good it is, you need to be sure that you can afford it and that it won't leave you in a worse financial position.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's the indirect cost?
&lt;/h3&gt;

&lt;p&gt;As well as the advertised price, there are other costs involved. Most Bootcamps run full time which will mean you will either need to leave your job or drastically decrease your hours. This might be the right thing to do, but take into consideration the income you will lose from doing less, or no work. If you can take a career break or a sabbatical, then this will be less of a risk than if you have to quit your job. But you will still need to find a way to support yourself while you study.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is there a guaranteed job?
&lt;/h3&gt;

&lt;p&gt;Another factor to take into consideration is whether the bootcamp offers a guaranteed job at the end of the course. Make sure to read the terms and conditions carefully to be sure you're actually getting what you think you're getting.&lt;/p&gt;

&lt;h3&gt;
  
  
  What employers do they work with?
&lt;/h3&gt;

&lt;p&gt;One of the most valuable things about doing a bootcamp is the connections that the organizers have with employers. Before you start a bootcamp, find out what employers they work with and how you'll be able to interact with them. It's also worth asking how they prepare you for employment. Do they teach you how to write a coding resume? Will they invite local employers or recruiters to talk to you about the process?&lt;/p&gt;

&lt;h3&gt;
  
  
  Do they have experience running Bootcamps?
&lt;/h3&gt;

&lt;p&gt;Are they a new operation or have they been running for a long time? Just because they've been around for a while doesn't mean they'll be better but they would have had more time to iron out any kinks in their operation. If it's the very first time they're running the course then be prepared to be a bit of a guinea pig while they figure out how best to run it. It will also be easier to find out what previous students thought of the course. Have a look around in a few different places for online reviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who are the instructors?
&lt;/h3&gt;

&lt;p&gt;Most bootcamp instructors will be industry experts but it is worth doing a bit of research and finding out what experience they actually have. Although it's tempting to think that the more experience the instructor has the better, the crucial thing is actually how experienced they are as a teacher. Someone can have all the experience in the world, but if they're no good at explaining it to you then you'll have wasted your time. Check to see if the instructors have experience in running previous Bootcamps or another teaching role.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do you know the basics?
&lt;/h3&gt;

&lt;p&gt;While lots of Bootcamps will say that you don’t need prior coding knowledge, you will be doing yourself a huge favor if you learn a bit before you start. That way you'll be able to hit the ground running when you start the bootcamp and use the first few days as a recap on what you've learned. I would recommend looking for some free tutorials on YouTube or a site like freeCodeCamp. Learn some HTML and CSS and if you've got time learn the basics of how JavaScript works. This will give you the best possible head start for your bootcamp.&lt;/p&gt;




&lt;p&gt;Hopefully, this article has helped you decide if a bootcamp is right for you. Bootcamps are often very expensive. Even if it's free you're paying with your time and lost income. But the potential rewards for completing a bootcamp are also great. It can give you more credibility when applying for jobs, allow you to network with other programmers, and turbo-charge your learning.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>bootcamp</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What's the difference between var, const and let</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Fri, 11 Feb 2022 17:59:41 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/whats-the-difference-between-var-const-and-let-309j</link>
      <guid>https://dev.to/johnpalmgren/whats-the-difference-between-var-const-and-let-309j</guid>
      <description>&lt;h2&gt;
  
  
  The quick answer:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; has a different "scope" and it's normally better to use &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;const&lt;/code&gt; is for variables that will not be updated&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; is for variables that will be updated&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Var
&lt;/h2&gt;

&lt;p&gt;Before &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; the only way to declare a variable was with &lt;code&gt;var&lt;/code&gt;. The sope of &lt;code&gt;var&lt;/code&gt; -- where it can be accessed after it's been defined -- is global and function. So if it is defined outside a function it is globally scoped and available anywhere in the program. If it's defined in a function then it is function scoped and only available in that function. &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; on the other hand are block scoped. They are available in whatever block they are defined in. A block is anything inside curly brackets &lt;code&gt;{}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The use of &lt;code&gt;var&lt;/code&gt; can be confusing in blocks such as for-loops where you can inadvertently update the global scope, when you only want to update the block scope. For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 0; i &amp;lt; 5; i++){
  console.log(i) // 0/1/2/3/4
}
console.log(i) //undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (var i = 0; i &amp;lt; 5; i++){
  console.log(i) // 1/2/3/4
}
console.log(i) // 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this reason it is preferable to use &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; over &lt;code&gt;var&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  const
&lt;/h2&gt;

&lt;p&gt;When you assign a value to a variable using the &lt;code&gt;const&lt;/code&gt; keyword you tell JavaScript that you won't assign a new value to it. If you try, you will get an error. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643121653526%2Fj3Pz2tSyW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643121653526%2Fj3Pz2tSyW.png" alt="Untitled (Postcard) (1).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is worth remembering that while you can't update &lt;code&gt;const&lt;/code&gt; with a new value, you can still change the content of the variable. This is the case in objects and arrays. The below is valid&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643125125410%2Fyo-qqVmTa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643125125410%2Fyo-qqVmTa.png" alt="Untitled design (9).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  let
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;let&lt;/code&gt; when you will need to update a variable later in your program. You still can't reassign a &lt;code&gt;let&lt;/code&gt; variable once it's been declared. For instance you &lt;strong&gt;couldn't&lt;/strong&gt; use &lt;code&gt;let cat = "mogy"&lt;/code&gt; and then &lt;code&gt;let cat = "felix"&lt;/code&gt; but you can update the variable with &lt;code&gt;cat = "felix"&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Unlike with const, you an initialize a variable with &lt;code&gt;let&lt;/code&gt; without assigning it a value. The variable will then be undefined until you update it with a value&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let number // number is undefined
number = 5 // number is 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding truthy and falsy in JavaScript</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Mon, 07 Feb 2022 18:12:47 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/understanding-truthy-and-falsy-in-javascript-b82</link>
      <guid>https://dev.to/johnpalmgren/understanding-truthy-and-falsy-in-javascript-b82</guid>
      <description>&lt;p&gt;We know that variables in JavaScript can hold a Boolean value of true or false. As well as this, other JavaScript values equate to &lt;strong&gt;truthy&lt;/strong&gt; or &lt;strong&gt;falsy&lt;/strong&gt;. What does this mean? Variables that don’t have a Boolean data type are still treated in a similar as true or false. There are 7 falsy values in JavaScript and everything else it Truthy&lt;/p&gt;

&lt;h2&gt;
  
  
  Falsy
&lt;/h2&gt;

&lt;p&gt;The 7 Falsy values are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;false&lt;/li&gt;
&lt;li&gt;0&lt;/li&gt;
&lt;li&gt;0n:  zero as a BigInt&lt;/li&gt;
&lt;li&gt;“”: empty string &lt;/li&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;li&gt;undefined&lt;/li&gt;
&lt;li&gt;NaN&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can check that the values are treated as false by assigning some falsy values to variables. Then using the &lt;code&gt;!&lt;/code&gt; operator we can console log if the statement is not true. Here we say if not test1 and not test2 and not test3 log "falsy".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const test1 = "" // empty string
const test2 = 0 // zero
const test3 = parseFloat("hi") // NaN 

if(!test1 &amp;amp;&amp;amp; !test2 &amp;amp;&amp;amp; !test3){
  console.log("falsy")
} // logs falsy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Truthy
&lt;/h2&gt;

&lt;p&gt;Truthy values are everything that’s not in the above list. We can use similar code as above to check. You can see that even &lt;strong&gt;empty objects and arrays are truthy&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const test1 = "hi" // non-empty string
const test2 = 2 // non-zero number
const test3 = {} // empty object

if(test1 &amp;amp;&amp;amp; test2 &amp;amp;&amp;amp; test3){
  console.log("truthy")
} // returns truthy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The truth is out there: truth vs truthy
&lt;/h2&gt;

&lt;p&gt;It is important to bear in mind that truth and truthy are not the same thing. As is also the case for falsy and false. While an &lt;code&gt;if&lt;/code&gt; statement will work the same whether something is true or truthy, if you were to use &lt;code&gt;===&lt;/code&gt; to check the equality the results would not be the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const test1 = "hi" === true // test1 is false
const test2 = 2 === true // test2 is false
const test3 = [] === true // test3 is false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need to you can turn falsy results to false and truthy results to true using &lt;code&gt;!!&lt;/code&gt;. While &lt;code&gt;"hi"&lt;/code&gt; is truthy &lt;code&gt;!"hi"&lt;/code&gt; is false not falsy. Therefore &lt;code&gt;!!"hi"&lt;/code&gt; is the opposite of false and is true, not truthy. &lt;/p&gt;

&lt;h2&gt;
  
  
  Applications
&lt;/h2&gt;

&lt;p&gt;There are many use cases for truthy and falsy values. It can be very helpful when dealing with user input and catching errors as you can check whether something is &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt; or &lt;code&gt;NaN&lt;/code&gt;. You can also use it to check that a submitted form field is not blank as empty stings are falsy. There are of course plenty of other ways to do this but it is a useful thing to know. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is JavaScript Strict Mode?</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Thu, 03 Feb 2022 15:30:55 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/what-is-javascript-strict-mode-5g30</link>
      <guid>https://dev.to/johnpalmgren/what-is-javascript-strict-mode-5g30</guid>
      <description>&lt;h2&gt;
  
  
  What is Strict Mode?
&lt;/h2&gt;

&lt;p&gt;Strict mode is a way to make JavaScript errors more obvious. It can make the code more optimized for performance and prevent some security vulnerabilities. &lt;/p&gt;

&lt;p&gt;You can get away with a lot in JavaScript. The language is very forgiving and many errors or things that could lead to errors are ignored. This can make it an easy language to learn because you're is not bombarded with syntax errors. But it can cause problems further down the line.&lt;/p&gt;

&lt;p&gt;Strict Mode is a way to make JavaScript throw errors when it sees these mistakes which makes it easier to debug code and write better code in the first place. &lt;/p&gt;

&lt;h3&gt;
  
  
  Invoking strict mode
&lt;/h3&gt;

&lt;p&gt;To invoke strict mode, use the syntax &lt;code&gt;"use strict";&lt;/code&gt; or &lt;code&gt;'use strict';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Strict mode can apply to a whole script or individual functions. For scripts, write &lt;code&gt;"use strict"&lt;/code&gt; at the top of the script. For functions, you would put &lt;code&gt;"use strict"&lt;/code&gt; at the top of the function body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function example() {
    "use strict"
    return "this is an example function"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modules and Functions in JavaScript are automatically in strict mode. &lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  converting mistakes into errors
&lt;/h3&gt;

&lt;p&gt;Regular or "sloppy mode" JavaScript will allow a number of mistakes to pass by without causing any error messages. As mentioned earlier, this can make debugging difficult if your code stops working as you intend it. &lt;/p&gt;

&lt;p&gt;One of the things strict mode stops you from doing is assigning a variable without using the &lt;code&gt;const&lt;/code&gt; &lt;code&gt;let&lt;/code&gt; or &lt;code&gt;var&lt;/code&gt; keywords. In regular JavaScript, this would create a variable in the global scope and would continue to work. However, it's not the behavior we want. It creates the risk that you could misspell a variable and accidentally create a new variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      let number = 10;

      //misspelled variable will create new global variable
      // where the desired behavior is to update number variable
      numbr = 20

      console.log(number) //10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      "use strict"

      let number = 10;
      numbr = 20 // throws error

      console.log(number) //only error output shown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another mistake that won't show up in regular JavaScript is assigning a value to a non-writeable variable. An example of a non-writeable variable is &lt;code&gt;NaN&lt;/code&gt;. A mistake like &lt;code&gt;NaN = 10;&lt;/code&gt; will only throw an error in strict mode. Another example of this would be &lt;code&gt;undefined = "string"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Strict mode Will also prevent you from setting properties on primitive values. A primitive value is data that is not an object and has no methods. There are 7 primitive data types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;string&lt;/li&gt;
&lt;li&gt;number&lt;/li&gt;
&lt;li&gt;bigint&lt;/li&gt;
&lt;li&gt;boolean&lt;/li&gt;
&lt;li&gt;undefined&lt;/li&gt;
&lt;li&gt;symbol&lt;/li&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Setting a property on a primitive would look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      "use strict"
      true.string = "hi" // typeError
      "string".update = 10 // typeError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some other mistakes that strict mode will turn into errors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trying to delete an undeletable property&lt;/li&gt;
&lt;li&gt;Having the same names in a parameter eg &lt;code&gt;function myFunc(a, a, b) {...}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Prefixing numbers with a 0. Find out why &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Optimizing variable use in JavaScript
&lt;/h2&gt;

&lt;p&gt;Strict mode prevents certain actions which can lead to the code being less optimized. The JavaScript compiler is often able to say in which location each variable is stored. The variable name is mapped to its definition. This creates more optimized code. However, there are properties in JavaScript that make this impossible. Strict mode prevents these. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;with&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Strict mode prevents the use of the &lt;code&gt;with&lt;/code&gt; property. &lt;code&gt;with&lt;/code&gt; makes the properties of an object available as local variables in the statement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      const myObject = { 
        title: "don't make me think", 
        author: "Steve Krug" 
      };

      with (myObject) {
        console.log (`this book was written by ${author}`) 
        // This book was written by Steve Krug

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

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;with&lt;/code&gt; is &lt;strong&gt;not recommended&lt;/strong&gt; because any variable inside the block might relate to a property of the object &lt;strong&gt;or&lt;/strong&gt; a variable in the surrounding scope. Because this can only be evaluated at runtime it prevents the code from being optimized. For this reason, using &lt;code&gt;with&lt;/code&gt; in strict mode will throw an error.   &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;eval&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Like &lt;code&gt;with&lt;/code&gt;, &lt;code&gt;eval&lt;/code&gt; makes optimizing javascript code difficult. &lt;code&gt;eval&lt;/code&gt; is a function that takes a string and evaluates it as JavaScript code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cont x = 5
eval("x + 5") // 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem with eval (apart from its &lt;a href="https://stackoverflow.com/questions/86513/why-is-using-the-javascript-eval-function-a-bad-idea"&gt;security vulnerability&lt;/a&gt;) is that it can introduce a variable into the surrounding scope. This means that code inside the &lt;code&gt;eval&lt;/code&gt; function can change or override variables outside the function. And because JavaScript cannot check this until runtime, it can cause inefficiency. &lt;/p&gt;

&lt;p&gt;In strict mode, any variables created in &lt;code&gt;eval&lt;/code&gt; only exist within that function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    eval("x = 5")
    console.log(x) // 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    "use strict"
    eval("x = 5")
    console.log(x) // ReferenceError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Simplifying &lt;code&gt;eval&lt;/code&gt; and &lt;code&gt;arguments&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In Javascript &lt;code&gt;eval&lt;/code&gt; and &lt;code&gt;arguments&lt;/code&gt; behave in ways that you might not expect. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode"&gt;Mozilla&lt;/a&gt; says of the two: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Strict mode makes &lt;code&gt;arguments&lt;/code&gt; and &lt;code&gt;eval&lt;/code&gt; less bizarrely magical. Both involve a considerable amount of magical behavior in normal code: &lt;code&gt;eval&lt;/code&gt; to add or remove bindings and to change binding values, and &lt;code&gt;arguments&lt;/code&gt; by its indexed properties aliasing named arguments.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By using strict mode, &lt;code&gt;eval&lt;/code&gt; and &lt;code&gt;arguments&lt;/code&gt; are treated more like normal keywords&lt;/p&gt;

&lt;h2&gt;
  
  
  Making JavaScript more secure
&lt;/h2&gt;

&lt;p&gt;JavaScript can be manipulated in the browser so that a person's private information can be accessed. JavaScript can prevent this from happening by partially transforming the JavaScript before it is run. However, if the code is not written well, this can take a lot of resources at runtime. Strict mode forces you to write JavaScript that will be more secure. &lt;/p&gt;

&lt;p&gt;Without strict mode, it could be possible to access the global object from a function. This can then be used to manipulate JavaScript in ways that present a security risk. This has to do with the &lt;code&gt;this&lt;/code&gt; value that is passed to the function. Because strict mode prevents &lt;code&gt;this&lt;/code&gt; from being forced into an object, and if unspecified it will be &lt;code&gt;undefined&lt;/code&gt;, malicious actors will not be able to access the &lt;code&gt;global&lt;/code&gt; or &lt;code&gt;window&lt;/code&gt; object. Read more about &lt;code&gt;this&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another security vulnerability in functions that strict mode sets out to fix is in JavaScript extensions. Using the extension &lt;code&gt;.caller&lt;/code&gt; when a function is being called, will reveal the function that called it, and &lt;code&gt;.arguments&lt;/code&gt; shows its arguments. This can allow access to potentially unsecured arguments through "secure" functions. If anyone tries to access &lt;code&gt;.caller&lt;/code&gt; or &lt;code&gt;.arguments&lt;/code&gt; in strict mode code the result will be a &lt;code&gt;TypeError&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  New Keywords
&lt;/h2&gt;

&lt;p&gt;In strict mode, there are some extra reserved keywords. These are words that are likely to be used in future versions of JavaScript. Their inclusion acts to ease the transition into newer versions of JavaScript. Some of these are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;implements&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;interface&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;package&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;private&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;protected&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;public&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;static&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;yield&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For extra information on strict mode and more technical explanation on what it does, you can see the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode"&gt;Mozilla documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Advanced array methods: array.forEach array.filter &amp; array.map</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Wed, 02 Feb 2022 15:43:07 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/advanced-array-methods-arrayforeach-arrayfilter-arraymap-4mh3</link>
      <guid>https://dev.to/johnpalmgren/advanced-array-methods-arrayforeach-arrayfilter-arraymap-4mh3</guid>
      <description>&lt;p&gt;&lt;code&gt;array.forEach&lt;/code&gt;,  &lt;code&gt;array.filter&lt;/code&gt; &amp;amp; &lt;code&gt;array.map&lt;/code&gt; are array methods which take functions as arguments. Below we will look at how they work.&lt;/p&gt;

&lt;h2&gt;
  
  
  forEach
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;.forEach&lt;/code&gt; will loop through an array and perform an action (execute a function) for every iteration in that loop. This is how it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let string = "My tech stack is:"

const technologies = [" Mongo DB,", " Express.js,", " React.js,", " Node.js"]

technologies.forEach(myFunction)

 function myFunction (item) {
    string += item
}

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K8IM6TIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642601153290/BW-JX77ec.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K8IM6TIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642601153290/BW-JX77ec.png" alt="My tech stack is Mongo DB, Express.js, React.js, Node.js" width="824" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, we loop through each item in the array and call &lt;code&gt;myFunction&lt;/code&gt; on each item. &lt;code&gt;myFunction&lt;/code&gt; then adds each item to the string.&lt;/p&gt;

&lt;p&gt;As with all of the array methods in this blog, it is common to use anonymous functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;technologies.forEach((item) =&amp;gt; {
  string += item
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We could also do this with a &lt;code&gt;for of&lt;/code&gt; loop but it may not be as easy to read. Although there are some small differences in how they are carried out, it's just personal preference as to which one to use.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Another way to do the same thing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i of technologies) {
  string += i
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;forEach&lt;/code&gt; also takes some additional optional arguments: index and array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;technologies.forEach((item, index, arr) =&amp;gt; {
  string += index[arr]
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The index provides the current index of each item in the array and the array provides access to the whole array on each iteration. The above example will provide the same output as before: the index will be 0 on the first iteration, 1 on the second, and so on, and the array will be the whole array. In this example &lt;code&gt;index[0] === "Mongo DO"&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Filter
&lt;/h2&gt;

&lt;p&gt;The filter array method will loop through every item in the array, check it against a condition, and return a new array with items that meet that condition. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

function myFunction(item) {
  return (item &amp;lt; 10)
}

const lessThan10 = numbers.filter(myFunction)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2xk-FCSI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642603981199/DdeA1Vyg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2xk-FCSI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642603981199/DdeA1Vyg9.png" alt="0,1,1,2,3,5,8" width="196" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The function &lt;code&gt;myFunction&lt;/code&gt; is executed for every iteration in the loop and each item is checked against the condition in the function. If it "passes" the condition, in this case being less than 10, then it is added to the new array &lt;code&gt;lessThan10&lt;/code&gt;. Don't forget that you need to &lt;code&gt;return&lt;/code&gt; the condition in your function.&lt;/p&gt;

&lt;p&gt;As before, this can also be done with a for loop but it does take more code to write out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newArr = []

for (i of numbers) {
  if (i &amp;lt; 10) {
    newArr.push(i)
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filter can also take the optional arguments: index and array. As with &lt;code&gt;forEach&lt;/code&gt; this gives you access to the current index and the whole array  on each iteration of the loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myFunction(item, index, arr) {
  return (arr[index] &amp;lt; 10)
}

const lessThan10 = numbers.filter(myFunction)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Map
&lt;/h2&gt;

&lt;p&gt;Map iterates through each element in an array and calls a function on each iteration. This can be used to make a change to each item in the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

function tenX(item) {
  return (item * 10)
}

const biggerNumbers = numbers.map(tenX)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which of course gives us 0, 10, 10, 20, 30, 50, 80, 130, 210, 340&lt;/p&gt;

&lt;p&gt;You can use the function passed to map to manipulate the array in any way you like, making it useful for creating elements to add to the DOM. In the below example there is an array of strings. The map method calls a function which creates a new &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, creates a class and adds it to an existing element in the DOM. This is done for each item in the array. &lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;array.forEach&lt;/code&gt;, &lt;code&gt;array.filter&lt;/code&gt; and &lt;code&gt;array.map&lt;/code&gt; are great ways to manipulate arrays in JavaScript. They are easier to read than for loops and often involve writing less code. This is particularly true if you are trying to do something more complex with the arrays. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to become a web developer in 2022. What I've learned from teaching myself web development.</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Tue, 01 Feb 2022 18:41:34 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/how-to-become-a-web-developer-in-2022-what-ive-learned-from-teaching-myself-web-development-23ml</link>
      <guid>https://dev.to/johnpalmgren/how-to-become-a-web-developer-in-2022-what-ive-learned-from-teaching-myself-web-development-23ml</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f9i-mgXs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515753071/CuEEUzwf8.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f9i-mgXs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515753071/CuEEUzwf8.jpeg" alt="nick-morrison-FHnnjk1Yj7Y-unsplash.jpg" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Teaching yourself web development has never been easier. There are hundreds of free courses, free books and bundles of content on YouTube. There are also reasonably priced resources and some very expensive options like Bootcamps. You can go from not knowing what a variable is, to getting your first job, without having to leave your house. Yet, learning to become a web developer is not easy. It will take hundreds of hours and dedication to push through those inevitable periods of low motivation. If you're not taking a formal course like a Bootcamp or a degree you will also need to create your own learning pathway, by selecting the skills that you think are valuable and deciding how much time to spend learning them. It will always be a case of trial and error and there is no perfect way to do this. &lt;/p&gt;

&lt;h2&gt;
  
  
  Learning to learn
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TggW4lXO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515615831/rvlm95D1w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TggW4lXO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515615831/rvlm95D1w.jpeg" alt="tim-mossholder-WE_Kv_ZB1l0-unsplash.jpg" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It sounds obvious, but if you're about to embark on the journey of teaching yourself web development, you're going to have to learn a lot. Any job advert will have a list as long as your arm with all the technologies they want their devs to know. The quote by Abraham Lincoln is overused but no less relevant here: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Give me 6 hours to chop down a tree and I will spend the first 4 sharpening the axe". &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's worth spending time before you get started to think about how you learn. Do you absorb information better if you read it or hear it? Do you learn by doing or by making notes? I learn best by listening to people so I've got the bulk of my knowledge from online courses, YouTube and podcasts rather than books and blogs. &lt;/p&gt;

&lt;p&gt;This is absolutely not essential to becoming a good developer but I find understanding the learning process really interesting. If you're interested too a couple of my favorite books on the topic are  &lt;a href="https://www.amazon.com/Peak-Performance-Elevate-Burnout-Science/dp/162336793X/ref=tmm_hrd_swatch_0?_encoding=UTF8&amp;amp;qid=1642427842&amp;amp;sr=8-1"&gt;Peak Performance&lt;/a&gt; and  &lt;a href="https://www.amazon.com/Talent-Code-Greatness-born-grown/dp/1847943047/ref=tmm_pap_swatch_0?_encoding=UTF8&amp;amp;qid=1642427939&amp;amp;sr=8-1"&gt;Talent Code&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Don't jump ship
&lt;/h2&gt;

&lt;p&gt;This is a tricky one. If you start learning something and you're really not enjoying it, then trying something else might be the right thing to do. However, no matter what you're learning, you're going to go through stages where what you're doing seems hard, or boring, or irrelevant. The grass is always greener on the other side, as they say, and it's all too easy to decide what you actually need to learn is C# or Ruby or TypeScript. Chose a programming language and stick to it. Once you've developed a certain level of proficiency you can learn more.  That's not to say that you should never change your mind but give it a lot of thought before you do. &lt;/p&gt;

&lt;h2&gt;
  
  
  Don't go too deep
&lt;/h2&gt;

&lt;p&gt;While It's important to pick a language and stick with it, to be a web developer you will need many strings to your bow and you'll need to build a broad base of knowledge. For this reason, you don't want to become an expert on one technology before you start learning something else. It's great to have deep knowledge but you don't need to know absolutely everything about CSS (you never will) before you start learning JavaScript; and you don't need to be an expert in JavaScript before you start learning React. Learn the basics, get some practice, then learn something new. Just remember to keep going back to it and adding to your knowledge. &lt;/p&gt;

&lt;h2&gt;
  
  
  Learn the easy stuff first
&lt;/h2&gt;

&lt;p&gt;I should say learn the easier stuff here. It should be hard enough to hold your attention and avoid you getting bored. What you want to avoid is getting so excited that you throw yourself into the really hard stuff, and end up stuck and demotivated after a few weeks. It's worth saying that everyone is different and we all have our own ways of learning so if this is what works for you then go ahead. That being said, you'll get a lot more done in the long run if you do something which you find enjoyable at a pace that you can maintain. &lt;/p&gt;

&lt;p&gt;A few years ago I was interested in Machine Learning and instead of using pre-built tools to build some cool stuff I decided that I first needed to learn all the linear algebra and multivariate calculus that I might need to build a machine learning program. Needless to say, I didn't carry on with it for more than a couple of months. &lt;/p&gt;

&lt;p&gt;If you're really into learning algorithms and design patterns or reading through documentation then do that but if you're not then start by building stuff and having fun.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The Tutorial Trap
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2GSLXYB---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515949837/qVC8JlMqG.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2GSLXYB---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515949837/qVC8JlMqG.jpeg" alt="christian-wiediger-NmGzVG5Wsg8-unsplash.jpg" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many people have written about the tutorial trap. This is where you get stuck watching tutorials but never seem to make any progress. If you feel like you forget &lt;br&gt;
 everything you learn as soon as you learn it, you may have fallen into the tutorial trap. &lt;/p&gt;

&lt;p&gt;Here's the thing: It's actually very hard to just listen to tutorials and code along and actually remember what you've learned. If you're starting completely from scratch then it might be useful to watch a tutorial and code along line by line. If you're not, then it's best to use tutorials to introduce yourself to a topic or find one when you're stuck but just try and figure it out on your own the rest of the time. &lt;/p&gt;

&lt;p&gt;We learn best when what we are attempting is challenging enough to keep us interested but not so challenging that we have no way to do it. Watching too many tutorials and just coding along isn't challenging enough (unless you're completely new to the topic). A far better way to learn is to &lt;strong&gt;start doing projects&lt;/strong&gt;. If you don't think you know enough to start doing projects yet, you can  &lt;a href="https://johnpalmgren.hashnode.dev/build-your-first-html-webpage-in-under-30-minutes"&gt;build a simple web page&lt;/a&gt;  after spending a few hours studying HTML.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn things other than programming
&lt;/h2&gt;

&lt;p&gt;As I mentioned earlier, if you want to get a dev job there's a whole list of technologies that you need to know. But some of the most important skills are ones that you don't get while staring at a code editor. Soft skills are very important for any coding job. Good verbal and written communication and the ability to work well in a team will go a long way in helping you land your first tech job. &lt;/p&gt;

&lt;p&gt;As well as soft skills, knowing some of the big picture stuff can make you into a more well-rounded programmer.  Knowing some computer science and web fundamentals is always good. Also, having a basic understanding of how SEO works and things like Agile project management, which is often used by tech companies, will certainly not hurt. There are plenty of free introductory courses for all of the above.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Be consistent
&lt;/h2&gt;

&lt;p&gt;Here's another book recommendation:  &lt;a href="https://www.amazon.com/Atomic-Habits-James-Clear/dp/1847941834/ref=tmm_pap_swatch_0?_encoding=UTF8&amp;amp;qid=1642429392&amp;amp;sr=8-1"&gt;Atomic Habbits&lt;/a&gt;  by  &lt;a href="https://twitter.com/JamesClear"&gt;James Clear&lt;/a&gt;. In his book he talks about how taking some small positive action every day compound over time to make a big impact. This is a great way to think about your coding journey. Doing all-nighter coding sessions is fine if that's how you work but teaching yourself to be a developer is a marathon not a sprint. Being able to turn up and work consistently, no matter whether you're in the mood or not, will determine how successful you'll be. &lt;/p&gt;

&lt;h2&gt;
  
  
  Join a Community
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1xoq346N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515968861/FdbElN9yp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1xoq346N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1642515968861/FdbElN9yp.jpeg" alt="brooke-cagle-g1Kr4Ozfoac-unsplash.jpg" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How do you stay consistent? You need to share your journey with other people. Teaching yourself to code takes a long time and the best way to stay motivated is to have a community around you that is doing the same thing. There are lots of ways to connect to a community: many online courses have forums where you can connect with people. Some courses even have pre-build communities on platforms like discord and you can jump right in and get to know people. There's also Twitter and other social media. Just make sure that you're spending time with people who are constructive and want the best for you. &lt;/p&gt;

&lt;p&gt;There are, of course, also offline communities that it is worth being a part of. Keep a lookout for tech meetup groups in your area. It will not only help you stay motivated but it's a great way to network and meet people already in the industry. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CSS variables: What are they and how to use them</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Wed, 26 Jan 2022 13:55:09 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/css-variables-what-are-they-and-how-to-use-them-5426</link>
      <guid>https://dev.to/johnpalmgren/css-variables-what-are-they-and-how-to-use-them-5426</guid>
      <description>&lt;h2&gt;
  
  
  What are they
&lt;/h2&gt;

&lt;p&gt;CSS custom properties aka CSS variables allow you to define a property in a variable that you can use over and over again. There are a number of use cases for this: often you will use the same colors for a brand or a particular theme. The big benefit of using variables for commonly used properties is that if you need to change it further down the line you can simply change the variable. This will save you from having to find everywhere in your code that you used that property.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use them
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Apply the variable to an element
&lt;/h3&gt;

&lt;p&gt;You first need to declare what element it should be applied to. You can apply it to any element but it is common to apply it to the root element so it can be used anywhere in your CSS (global scope). Use the &lt;code&gt;:element {}&lt;/code&gt; syntax to select the element. You can choose any name for your variables but they are case sensitive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
  --bg-color: #4B6CDB;
  --text-color: #fff;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Calling the variable
&lt;/h3&gt;

&lt;p&gt;You can call the variable by using &lt;code&gt;var()&lt;/code&gt;.  Instead of putting in the property name call the variable name inside the var function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.myClass {
  background-color: var(--bg-color)
  color: var(--text-color)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>css</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CSS Hacks: What is ::before and ::after?</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Tue, 25 Jan 2022 15:47:35 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/css-hacks-what-is-before-and-after-2963</link>
      <guid>https://dev.to/johnpalmgren/css-hacks-what-is-before-and-after-2963</guid>
      <description>&lt;p&gt;&lt;code&gt;::before&lt;/code&gt; and &lt;code&gt;::after&lt;/code&gt; are CSS pseudo elements. They can &lt;strong&gt;add&lt;/strong&gt; content before or after that element. This is the syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.class::after {
  content: "some content"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be used with pseudo classes to add content when an event occurs. In the example below text is added when there is a hover event. &lt;/p&gt;

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

&lt;p&gt;The ::before and ::after pseudo elements can also be added with no content &lt;code&gt;content:""&lt;/code&gt; and can be used to add styles to the document. The below example shows how you can add a border when hovering with &lt;code&gt;::after&lt;/code&gt; and the &lt;code&gt;transition&lt;/code&gt; property.&lt;/p&gt;

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

&lt;p&gt;What else can you do with &lt;code&gt;::before&lt;/code&gt; and &lt;code&gt;::after&lt;/code&gt;? Leave a comment below&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CSS Pseudo Selectors: What's the difference between :first-of-type and :first-child</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Mon, 24 Jan 2022 12:59:44 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/css-pseudo-selectors-whats-the-difference-between-first-of-type-and-first-child-19di</link>
      <guid>https://dev.to/johnpalmgren/css-pseudo-selectors-whats-the-difference-between-first-of-type-and-first-child-19di</guid>
      <description>&lt;p&gt;&lt;strong&gt;first-of-type&lt;/strong&gt; and &lt;strong&gt;first-child&lt;/strong&gt; are very similar pseudo selectors and will often target the same element. When they don't it can be confusing, so let's look at what they do.&lt;/p&gt;

&lt;h2&gt;
  
  
  First Child
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;first-child&lt;/code&gt; will look &lt;strong&gt;only&lt;/strong&gt; at the first child element. In &lt;strong&gt;example one&lt;/strong&gt; below &lt;code&gt;.example-one div:first-child {}&lt;/code&gt; will select the first  div. If we were to try that with &lt;strong&gt;example 2&lt;/strong&gt; and write &lt;code&gt;.example-two div:first-child {}&lt;/code&gt; it would select &lt;strong&gt;nothing&lt;/strong&gt;. This is because the first child is not a div, its a &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section class="example-one"&amp;gt; 
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/section&amp;gt;

&amp;lt;section class="example-two"&amp;gt;
&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;
&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  First of Type
&lt;/h2&gt;

&lt;p&gt;When you use the &lt;code&gt;first-of-type&lt;/code&gt; pseudo selector it will select the first child element that matches that type. Consider the same code as above but with &lt;code&gt;first-of-type&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;example-one div:first-of-type {}&lt;/code&gt; will still select the first &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;. This is because it's the &lt;strong&gt;first child&lt;/strong&gt;  and the &lt;strong&gt;first of type&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;example-two div:first-of-type {}&lt;/code&gt; &lt;strong&gt;doesn't&lt;/strong&gt; select nothing, like it did with &lt;code&gt;first-child&lt;/code&gt; but selects the second child which is the first element of type &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  What's the difference?
&lt;/h2&gt;

&lt;p&gt;There can be &lt;strong&gt;only one&lt;/strong&gt; element that matches the &lt;code&gt;first-child&lt;/code&gt; pseudo selector. This is because every parent element only has one element that is the first in that list. &lt;/p&gt;

&lt;p&gt;For every parent element, there can be &lt;strong&gt;many&lt;/strong&gt; &lt;code&gt;fist-of-type&lt;/code&gt; elements. Every element that is the child of a parent element can be selected with the &lt;code&gt;first-of-type&lt;/code&gt; pseudo selector. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MKRy30N0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641826708720/0xQs-gNXw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MKRy30N0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641826708720/0xQs-gNXw.png" alt="illustration of first-of-type / first-child" width="880" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Flexbox complete guide for beginners</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Fri, 21 Jan 2022 14:42:22 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/flexbox-complete-guide-for-beginners-56bp</link>
      <guid>https://dev.to/johnpalmgren/flexbox-complete-guide-for-beginners-56bp</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641632973684%2FoaPueBzsK.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641632973684%2FoaPueBzsK.jpeg" alt="watercolor illustration of webpage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is flexbox?
&lt;/h2&gt;

&lt;p&gt;Flexbox is a property that you can use in CSS that will position any child elements in accordance with a few simple rules. What does this mean? Well instead of spending a lot of time positioning elements with &lt;strong&gt;margins, position absolute&lt;/strong&gt; and &lt;strong&gt;float&lt;/strong&gt; you can just tell flexbox how you want all the elements to be displayed and let it take care of the hard work for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Flexbox Axis
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641646651277%2FLrAU2R3pI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641646651277%2FLrAU2R3pI.png" alt="left right top and down arrows"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Flexbox aligns the item in the flex container on either the main or the cross axis. Think of these as lines going from the top to bottom of the page and from left to right. The direction in flexbox can also be set to either row or column. If the direction is row then the main axis runs from the left to right of the page and the cross axis runs from top to bottom. If the direction is set to column then its the other way round: the main axis runs from top to bottom and the cross axis runs from side to side. Don't worry if this all sounds very confusing, as you start playing around with flexbox it will be easy to figure out. &lt;/p&gt;

&lt;h3&gt;
  
  
  Display
&lt;/h3&gt;

&lt;p&gt;The first thing you need to do is give your parent element a display property of flex&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.example {
    display: flex
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or for an inline element &lt;code&gt;display: inline-flex&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Flex direction
&lt;/h3&gt;

&lt;p&gt;You can now specify a flex direction. This has to do with, you guessed it, the direction your elements line up. Let's create some numbered &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section class="flexbox"&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;One&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;Two&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;Three&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;Four&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.flexbox div {
  background-color: blue;
  color: white;
  margin: 2px;
  width: 100px;
  height: 100px;
}

.flexbox {
  display: flex;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default for flexbox is &lt;code&gt;flex-direction:row&lt;/code&gt;. You can set this explicitly or leave it as default. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641637362370%2FJ9a76H8u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641637362370%2FJ9a76H8u5.png" alt="divs lined up in row"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set &lt;code&gt;flex direction&lt;/code&gt; to row reverse and you will see the order of the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s reversed&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641637751497%2FUcIyF-_lx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641637751497%2FUcIyF-_lx.png" alt="divs in reverse order"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The other two direction properties are &lt;code&gt;flex-direction: column;&lt;/code&gt; and &lt;code&gt;flex-direction: column-reverse;&lt;/code&gt;. As the name suggests this will order the contents of the container into a column in normal or reverse order. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641638254389%2FuiZ1mKjqLa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641638254389%2FuiZ1mKjqLa.png" alt="divs in a column in standard and reverse order"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Flex Wrap
&lt;/h3&gt;

&lt;p&gt;The Flex Wrap property defines what should happen when the size of the container is reduced so that the children no longer fit in it. When you have &lt;code&gt;flex-wrap: nowrap;&lt;/code&gt; the items will not drop onto the next line if they run out of space, instead, they will first reduce their width and then stop being visible in the viewport.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641639221289%2FZY5d-cNRP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641639221289%2FZY5d-cNRP.png" alt="divs being squeezed together"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex-wrap: wrap;&lt;/code&gt; on the other hand simply pushes the children onto the next line. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641639416514%2FtvIUshO8fk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641639416514%2FtvIUshO8fk.png" alt="one div is pushed onto the next line"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;flex-wrap: wrap-reverse;&lt;/code&gt; will do the same thing but populate the bottom line first&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641639587504%2F8zKO9euWu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641639587504%2F8zKO9euWu.png" alt="all but one div on bottom line"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Justify content
&lt;/h3&gt;

&lt;p&gt;Here's where flexbox comes into its own. Instead of spending hours with CSS positions only to add an extra element and find that it no longer works, with justify content you can position elements in relation to each other with just one property. Let's have another look at our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s to see how it works&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;justify-content: flex-start;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641640244255%2Ffbh-qn4C2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641640244255%2Ffbh-qn4C2.png" alt="divs justified left"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;justify-content: flex-end;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643208365%2FenOJONs_R.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643208365%2FenOJONs_R.png" alt="divs justified right"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;justify-content: center;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643301518%2FtwXxiYAh-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643301518%2FtwXxiYAh-.png" alt="divs justified centre"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;justify-content: space-around;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643398944%2FCEfn6mpXm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643398944%2FCEfn6mpXm.png" alt="divs equally spaced on page"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;justify-content: space-between;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643509604%2Fze_XIRwDK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643509604%2Fze_XIRwDK.png" alt="space between divs"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;justify-content: space-evenly;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643613045%2FXaE7vlY0B.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641643613045%2FXaE7vlY0B.png" alt="divs evenly spaced"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Align Items
&lt;/h2&gt;

&lt;p&gt;This property determine how items should be displayed on the cross axis. To illustrate this I've made the wrapping div container grey.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-items: flex-start;&lt;/code&gt; Keeps the items aligned to the top of the container&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644199334%2FhmD7I9FZI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644199334%2FhmD7I9FZI.png" alt="flex start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-items: flex-end;&lt;/code&gt; will align the items to the bottom of the container&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644181929%2FVxoiOj9iB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644181929%2FVxoiOj9iB.png" alt="flex end"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-items: center;&lt;/code&gt; will center the items horizontally. This is super useful as it's not always easy to do with regular CSS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644658440%2FPwjHOdZrB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644658440%2FPwjHOdZrB.png" alt="align items cetre"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-items: baseline;&lt;/code&gt; takes the first element in each flex item, and lines things up by the bottom of that element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644523789%2FV1zI8DKYsO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641644523789%2FV1zI8DKYsO.png" alt="align items baseline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-items: stretch;&lt;/code&gt; will stretch the items from the top to the bottom of the container as long as the height property is not set on the items&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641645125344%2Fwk9Xr-SSp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641645125344%2Fwk9Xr-SSp.png" alt="align items streach"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Align Content
&lt;/h3&gt;

&lt;p&gt;The align content property deals with how the items display when on multiple lines. For this reason, it will only take effect if the &lt;strong&gt;flexwrap&lt;/strong&gt; property is set to &lt;strong&gt;wrap&lt;/strong&gt; and the content is displayed over more than one line.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-content: flex-start;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641648897483%2FYAc7DL1de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641648897483%2FYAc7DL1de.png" alt="flex start"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-content: flex-end;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641648850531%2Fr4zVMTO9U.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641648850531%2Fr4zVMTO9U.png" alt="flex end"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-content: center;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641648986386%2FQliWHBFcJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641648986386%2FQliWHBFcJ.png" alt="align content centre"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-content: space-between;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641649050934%2FnA41X1xVl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641649050934%2FnA41X1xVl.png" alt="align content space between"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-content: space-around;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641649240407%2FKXeI6aM2do.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641649240407%2FKXeI6aM2do.png" alt="align-content space around"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-content: stretch;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641649370562%2FH0nz4SP3C.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641649370562%2FH0nz4SP3C.png" alt="align content stretch"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Flexbox children
&lt;/h2&gt;

&lt;p&gt;Flexbox children are properties which are given directly to the children in the flexbox container and control how they behave. &lt;/p&gt;

&lt;h3&gt;
  
  
  Order
&lt;/h3&gt;

&lt;p&gt;Order allows you to determine the order in which each element is displayed in the flex container. For example, lets give our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; number &lt;strong&gt;three&lt;/strong&gt; an order of -1&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;order: -1;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641654689169%2FE2Jxq1qMg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641654689169%2FE2Jxq1qMg.png" alt="div number three is a the front"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; number &lt;strong&gt;three&lt;/strong&gt; is at the front. This is because all items have a default order of 0 so the order is now -1, 0, 0, 0. If we change the order of &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; number &lt;strong&gt;three&lt;/strong&gt; to 1 we will then have 0, 0, 0, 1 and it will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;order: 1;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641654867383%2Fovgpl_RBR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641654867383%2Fovgpl_RBR.png" alt="div number 3 is at the back"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can of course give any div any order value and therefore place them in whichever order you wish. &lt;/p&gt;

&lt;h3&gt;
  
  
  Flex Grow
&lt;/h3&gt;

&lt;p&gt;Much like flex order, flex-grow is applied to one or more of the children in a flexbox container and will prioritize that child to grow to fill the available width while all other children stay the same size. Let's do that with &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; number &lt;strong&gt;three&lt;/strong&gt; again.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex-grow: 1;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641655214573%2FbyK07CfJ9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641655214573%2FbyK07CfJ9.png" alt="flex grow on div 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Flex Basis
&lt;/h3&gt;

&lt;p&gt;This defines the default size of a child element and all other elements will fit in around it. As with any other measurement you can give the size in pixels, rem or percent.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex-basis: 33%;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641655603868%2FDdoNAhMsa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641655603868%2FDdoNAhMsa.png" alt="flex basis"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Flex Shrink
&lt;/h3&gt;

&lt;p&gt;This sets the order in which items should shrink in the available space. The default value for all flex children is 1. If all other items stay at 1 and you change the value to 0 that element will grow to fill the available space. If you set it to 2 It will shrink, leaving the other items to fill the available space. In this example we'll set &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; &lt;strong&gt;two&lt;/strong&gt; and &lt;strong&gt;three&lt;/strong&gt; to a value of 2&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex-shrink: 2;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641656537554%2FdrAYPe_Ms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641656537554%2FdrAYPe_Ms.png" alt="flexbox shrink"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Now It's your turn
&lt;/h2&gt;

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

&lt;p&gt;You have two challenges. The CSS selectors have been provided. Just use flexbox to complete the challenge&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit the codepen to get the two sections to look like the picture below. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641657500893%2Fz42_W06F4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641657500893%2Fz42_W06F4.png" alt="challenge one"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit the codepen to center the words &lt;strong&gt;one two three&lt;/strong&gt; and &lt;strong&gt;four&lt;/strong&gt; in the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641659800594%2F6cy9d9ww-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641659800594%2F6cy9d9ww-.png" alt="challenge two"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>flexbox</category>
      <category>css</category>
    </item>
    <item>
      <title>3 Ways to add CSS to your website</title>
      <dc:creator>John Palmgren</dc:creator>
      <pubDate>Thu, 20 Jan 2022 15:20:50 +0000</pubDate>
      <link>https://dev.to/johnpalmgren/3-ways-to-add-css-to-your-website-2obh</link>
      <guid>https://dev.to/johnpalmgren/3-ways-to-add-css-to-your-website-2obh</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PfYmkDGC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641627344851/dt70vOLPb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PfYmkDGC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641627344851/dt70vOLPb.png" alt="two screens with colorful layout" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  what is CSS
&lt;/h2&gt;




&lt;blockquote&gt;
&lt;p&gt;Fashion Fades, style is eternal&lt;/p&gt;
&lt;h2&gt;
  
  
  YVES SAINT LAURENT
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;CSS is where we provide the style to our website. It tells the browser how to position the elements on the page, what color they should be, what font to use and almost anything else you can think of which relates to how the website looks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inline CSS
&lt;/h2&gt;

&lt;p&gt;You can add CSS directly into the HTML elements. You can do this with the style attribute. It will look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1 style="background-color:blue; color:yellow"&amp;gt;Hello World&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lbwH3p_m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641627720849/EriMFcOdk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lbwH3p_m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641627720849/EriMFcOdk.png" alt='yellow "hello world" text on blue background' width="880" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A couple of things to be aware of about using inline style&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It has the highest precedence. That means, if in the example above, I was to give the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; a different style using an internal or external style sheet it would not change the style.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is &lt;strong&gt;not recommended&lt;/strong&gt; to use this method — particularly in big projects. The reason for this is that it's easy to lose track of which styles you put where and if you want to make a change you have to search the whole document and make each change individually.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Internal CSS
&lt;/h2&gt;

&lt;p&gt;The second way to add CSS is in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of HTML page. You will need to add it in a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag. Don’t forget that you need to add the selector (h1 / p / body) because you’re not applying it directly to the element. It should look something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
      body {background-color: pink;}
      p {color:white; font-size:2rem;};
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UFs6o4Dh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641628088567/lPhtS_8vb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UFs6o4Dh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641628088567/lPhtS_8vb.png" alt="White text on pink background" width="880" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While there’s nothing wrong with using internal CSS it does mean, if you have many HTML pages with similar styles, you will end up writing the same code over and over again in the head of each file. A better way to do this would be with an external style sheet.&lt;/p&gt;

&lt;h2&gt;
  
  
  External CSS
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QhutAwCh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641628143562/Fl1UNZ7zR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QhutAwCh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641628143562/Fl1UNZ7zR.png" alt="picture of brackets" width="351" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most common way to use CSS is to have all your CSS rules in a separate CSS file and link that to any HTML files which will use it. First of all, you want to create a file ending .css where you will write all your CSS code. You may want to call it styles.css. Save this in the same folder as your HTML or a subfolder called styles or something similar. Then in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of your HTML, you will need to point to that CSS file. Use the format below, assuming your CSS file is called styles.css and it’s saved in your HTML folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
  &amp;lt;link rel="stylesheet" href="styles.css"&amp;gt;
&amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the &lt;code&gt;rel="stylesheet"&lt;/code&gt; tells the browser that this is our CSS stylesheet and the &lt;code&gt;href="styles.css"&lt;/code&gt; points to where this folder is located relative to the HTML document.&lt;/p&gt;



&lt;p&gt;The benefit of using external style sheets is that you can use the &lt;code&gt;href&lt;/code&gt; to import it into many HTML documents. An example of where this might be useful is if you have several pages with the same header. You can create the rules in one CSS stylesheet and import it to all the HTML documents with that header.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
