Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                <nav id="navbar">
  <header>Table of Contents</header>
  <ul>
  <li><a class="nav-link" href="#Introduction">Introduction</a></li>
  <li><a class="nav-link" href="#What_is_HTML">What is HTML</a></li>
  <li><a class="nav-link" href="#Images">Images</a></li>
  <li><a class="nav-link" href="#Marking_up_text">Marking Up Text</a></li>
  <li><a class="nav-link" href="#Links">Links</a></li>
  <li><a class="nav-link" href="#Conclusion">Conclusion</a></li>
  <li><a class="nav-link" href="#Reference">Reference</a></li>
</ul>
</nav>

<!-- Main --> 

<main id="main-doc">
  <section class="main-section" id="Introduction">
    <header>Introduction</header>
    <article>
      
      <p>
HTML (Hypertext Markup Language) is the code that is used to structure a web page and its content. For example, content could be structured within a set of paragraphs, a list of bulleted points, or using images and data tables. As the title suggests, this article will give you a basic understanding of HTML and its functions.
      </p>
    </article>
    
  </section>
  
 <!--What is HTML?--> 
  <section class="main-section" id="What_is_HTML">
    <header>What is HTML</header>
    <article>
     <p>HTML is a markup language that defines the structure of your content. HTML consists of a series of elements, which you use to enclose, or wrap, different parts of the content to make it appear a certain way, or act a certain way. The enclosing tags can make a word or image hyperlink to somewhere else, can italicize words, can make the font bigger or smaller, and so on.  For example, take the following line of content:
       <code>My cat is very grumpy</code>
         </p>
         
  <p>If we wanted the line to stand by itself, we could specify that it is a paragraph by enclosing it in paragraph tags:</p>
       
 <code> &lt;p&gt; My cat is very grumpy &lt;/p&gt; </code>
         
    </article>
  </section>
  
  <!--Images-->
  
    <section class="main-section" id="Images">
    <header>Images</header>
    <article>
      <p>Let's turn our attention to the image element again:</p>
       <code> &lt;img src="images/firefox-icon.png" alt="My test image"&gt;</code>
       
   <p> As we said before, it embeds an image into our page in the position it appears. It does this via the src (source) attribute, which contains the path to our image file.
 </p>

   <p>We have also included an alt (alternative) attribute. In this attribute, you specify descriptive text for users who cannot see the image, possibly because of the following reasons:</p>
    <ol>
      <li>They are visually impaired. Users with significant visual impairments often use tools called screen readers to read out the alt text to them.</li>
      <li>Something has gone wrong causing the image not to display. For example, try deliberately changing the path inside your src attribute to make it incorrect. If you save and reload the page, you should see something like this in place of the image:</li>
      </ol>
     <p>
  <img src="/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics/alt-text-example.png" alt="My Test Image" width="108" height="36" loading="lazy">
</p>
      <p>The keywords for alt text are "descriptive text". The alt text you write should provide the reader with enough information to have a good idea of what the image conveys. In this example, our current text of "My test image" is no good at all. A much better alternative for our Firefox logo would be "The Firefox logo: a flaming fox surrounding the Earth."

Try coming up with some better alt text for your image now.</p>
    </article>
  </section>
  
  <!--Marking up text -->
    <section class="main-section" id="Marking_up_text">
    <header>Marking Up Text</header>
    <article>
     <p>
       This section will cover some of the essential HTML elements you'll use for marking up the text.</p>
       
<h3>Headings</h3>
<p>      
Heading elements allow you to specify that certain parts of your content are headings — or subheadings. In the same way that a book has the main title, chapter titles, and subtitles, an HTML document can too. HTML contains 6 heading levels, "&lt;h1&gt;–&lt;h6&gt;", although you'll commonly only use 3 to 4 at most:
      </p>
      <code>
&lt;h1&gt; My main title &lt;/h1&gt;
&lt;h2&gt; My top level heading &lt;/h2&gt;
&lt;h3&gt; My subheading &lt;/h3&gt;
&lt;h4&gt; My sub-subheading &lt;/h4&gt;
      </code>      
 
      <p>Now try adding a suitable title to your HTML page just above your &lt;img&gt; element.</p>     
      
 <h3>Paragraphs</h3>
      
      <p>As explained above, elements are for containing paragraphs of text; you'll use these frequently when marking up regular text content:</p>
      
      <code>&lt;p&gt;This is a single paragraph&lt;/p&gt;</code>
      
      <h3>Lists</h3>
      <p>A lot of the web's content is lists and HTML has special elements for these. Marking up lists always consists of at least 2 elements. The most common list types are ordered and unordered lists:</p> 
      
      <ol>
        <li>Unordered lists are for lists where the order of the items doesn't matter, such as a shopping list. These are wrapped in a &lt;ul&gt; element.</li>
        <li>Ordered lists are for lists where the order of the items does matter, such as a recipe. These are wrapped in an &lt;ol&gt; element.</li>
      </ol>
 
      <p>Each item inside the lists is put inside an &lt;li&gt; (list item) element.</p>

<p>For example, if we wanted to turn the part of the following paragraph fragment into a list:</p>
      <code> &lt;p&gt; At Mozilla, we’re a global community of technologists, thinkers, and builders working together ... &lt;/p&gt;
</code>
 
<p>We could modify the markup to this:</p>
 
 <code>
&lt;p&gt; At Mozilla, we’re a global community of &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;technologists&lt;/li&gt;
  &lt;li&gt;thinkers&lt;/li&gt;
  &lt;li&gt;builders&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; working together ... &lt;/p&gt;
</code>
<p>Try adding an ordered or unordered list to your example page.</p>
    </article>
  </section>
      
 <!--Links--> 
      
 <section class="main-section" id="Links">
    <header>Links</header>
    <article>
     <p>
        Links are very important — they are what makes the web a web! To add a link, we need to use a simple element — &lt;a&gt; — "a" being the short form for "anchor". To make text within your paragraph into a link, follow these steps:
 </p>
      <ol>
        <li>Choose some text. We chose the text "Mozilla Manifesto".</li>
        <li>Wrap the text in an &lt;a&gt; element, as shown below: </li>
        
        <p><code> &lt;a&gt;Mozilla Manifesto&lt;/a&gt; </p></code>
        
        <li>Give the &lt;a&gt; element an href attribute, as shown below: </li>
        
        <p><code> &lt;a href="">Mozilla Manifesto &lt;/a&gt; </p></code>

        <li>Fill in the value of this attribute with the web address that you want the link to link to: </li>
        
        <p><code> &lt;a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto &lt;/a&gt; </p></code>
      </ol>
  
      <p>You might get unexpected results if you omit the https:// or http:// part, called the protocol, at the beginning of the web address. After making a link, click it to make sure it is sending you where you wanted it to.</p>     
      
    </article>
  </section>
  
<!--conclusion-->
  <section class="main-section" id="Conclusion">
    <header>Conclusion</header>
    <article>
     <p>
        If you have followed all the instructions in this article, you should end up with a page that looks like the one below (you can also view it here):
 </p>
      <img src="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics/finished-test-page-small.png" alt="Web page example">
      
    </article>
  </section>
 
 <!--Reference-->
  <section class="main-section" id="Reference">
    <header>Reference</header>
    <article>
     <ul>
       <li>
        All the documentation in this page is taken from <a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics" target="_blank">MDN</a>
       </li>
 </ul>
    </article>
  </section>
      </main>
              
            
!

CSS

              
                html,
body {
  min-width: 290px;
  color: #4d4e53;
  background-color: #ffffff;
  font-family: 'Open Sans', Arial, sans-serif;
  line-height: 1.5;
}

#navbar {
  position: fixed;
  min-width: 290px;
  top: 0px;
  left: 0px;
  width: 300px;
  height: 100%;
  border-right: solid;
  border-color: rgba(0, 22, 22, 0.4);
}

h2 {
  text-align:center;
}

header {
  color: black;
  margin: 10px;
  text-align: center;
  font-size: 1.8em;
}

#main-doc header {
  text-align: left;
  margin: 0px;
}

#navbar ul {
  height: 88%;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#navbar li {
  color: #4d4e53;
  border-top: 1px solid;
  list-style: none;
  position: relative;
  width: 100%;
}

#navbar li a:hover {
  background-color: #eee;
  color: black;
}

#navbar a {
  display: block;
  padding: 10px 30px;
  color: #4d4e53;
  text-decoration: none;
}

#main-doc {
  position: absolute;
  margin-left: 310px;
  padding: 20px;
  margin-bottom: 110px;
}

section article {
  color: #4d4e53;
  margin: 15px;
  font-size: 0.96em;
}

section li {
  margin: 15px 0px 0px 20px;
}

code {
  display: block;
  text-align: left;
  white-space: pre-line;
  position: relative;
  word-break: normal;
  word-wrap: normal;
  line-height: 2;
  background-color: #f7f7f7;
  padding: 15px;
  margin: 10px;
  border-radius: 5px;
}

@media only screen and (max-width: 815px) {
  /* For mobile phones: */
  #navbar ul {
    border: 1px solid;
    height: 207px;
  }
  
   #navbar {
    background-color: white;
    position: absolute;
    top: 0;
    padding: 0;
    margin: 0;
    width: 100%;
    max-height: 275px;
    border: none;
    z-index: 1;
    border-bottom: 2px solid;
  }
  
  #main-doc {
    position: relative;
    margin-left: 0px;
    margin-top: 270px;
  }
}


@media only screen and (max-width: 400px) {
  #main-doc {
    margin-left: -10px;
  }

  code {
    margin-left: -20px;
    width: 100%;
    padding: 15px;
    padding-left: 10px;
    padding-right: 45px;
    min-width: 233px;
  }
}

              
            
!

JS

              
                // !! IMPORTANT README:

// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place. 

/***********
INSTRUCTIONS:
  - Select the project you would 
    like to complete from the dropdown 
    menu.
  - Click the "RUN TESTS" button to
    run the tests against the blank 
    pen.
  - Click the "TESTS" button to see 
    the individual test cases. 
    (should all be failing at first)
  - Start coding! As you fulfill each
    test case, you will see them go   
    from red to green.
  - As you start to build out your 
    project, when tests are failing, 
    you should get helpful errors 
    along the way!
    ************/

// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!

// Once you have read the above messages, you can delete all comments. 

              
            
!
999px

Console