Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>4 Ways of Having Responsive Typography with CSS</h1>

<section class="media">
  <h2>With Media Queries</h2>  
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, modi. Dolores numquam nulla temporibus, repellat aliquam ab aspernatur ex suscipit recusandae error quisquam ipsa necessitatibus quos similique laboriosam assumenda omnis eius ipsam at. Optio reprehenderit expedita culpa architecto porro cum quas repellendus autem fugiat ex? Ipsum doloribus quisquam laboriosam. Explicabo!</p>
</section>

<section class="relative-units">
  
  <h2>Using Relative Units %,vw,vh</h2>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam totam perferendis tenetur expedita neque, dolorum porro officia hic reprehenderit iusto deleniti. Nobis fugit necessitatibus recusandae officia, maiores perferendis dignissimos? Dolore, voluptas molestias dolor explicabo odit porro quos laboriosam similique sit accusantium quidem ducimus neque dolores voluptatibus cumque tempora earum itaque?</p>
  
</section>

<section class="css-functions">
  <h2>Using clamp() & calc() </h2>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nesciunt modi voluptatum accusantium voluptates voluptatibus molestias labore et nostrum, repudiandae assumenda tempore blanditiis omnis quos eligendi, illo ex iure quas. Consequatur, explicabo possimus repellendus assumenda harum eligendi dolore veritatis illo doloremque, iure, modi aliquam tempora facere saepe debitis. Minus, similique est.</p>
</section>

<section class="css-var">
  <h2>Using CSS Variables </h2>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit laboriosam accusamus aut nam ad fuga deserunt et fugiat ut necessitatibus temporibus praesentium magnam, animi delectus corrupti eveniet voluptas possimus inventore aperiam hic tempora harum illum? Quia natus, fugit sint, commodi inventore illum facilis doloribus molestiae et, laboriosam expedita ducimus deleniti.</p>
</section>
              
            
!

CSS

              
                body{
  font-family:'Arial';
}

h1{
  text-align:center;
  text-transform:uppercase;
}

section{
  text-align:justify;
  border:2px solid #ededed;
  padding:20px;
  box-shadow:10px 10px 10px #ededed;
}

section h2{
  text-align:left;
}


/* 1. With Media Queries */
.media h2{
  font-size:2rem;
}
.media p{
  font-size:1.2rem;
}
/* Setting breakpoint for changing font size */

@media (max-width:768px) {
  .media{
    background:#ededed;
  }
  
  .media h2{
    font-size:1.5rem;
  }

  .media p{
    font-size:.8rem;
  }
}

/* Using Relative % Units */

.relative-units h2{
  font-size:5vw;
}

.relative-units p{
  font-size:2.5vw;
}

/* Using clamp() , calc() & minmax() */
/* When this method is combined with relative units it gives the best results */

.css-functions h2{
  font-size:calc(1.8rem + 2vw);
  /*  gives max size 👇   */
  font-size:clamp(1.8rem, 5vw , 2.5rem );
}

.css-functions p{
  font-size:clamp(.8rem, 4vw , 1.5rem );
  /*  does not give max size 👇   */
  font-size:calc(.7rem + 1vw);        
}

/* Using CSS Variables */

/* Setting Up Default Font size Variables  */
:root{
  --heading-2:2rem;
  --content:1rem;
}

/* Overidding Variables with Media Queries   */

@media(max-width:768px){
  :root{
    --heading-2:1.54rem;
    --content:.7rem;
  }
}

.css-var h2{
  font-size:var(--heading-2);
}

.css-var p{
  font-size:var(--content);
}

              
            
!

JS

              
                
              
            
!
999px

Console