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

              
                    <div id="page">
      <nav id="navbar">
        <header>
          <h2>Getting started with HTML</h2>
        </header>

        <ul>
          <li>
            <a class="nav-link" href="#Getting_started_with_HTML">
              Getting started with HTML
            </a>
          </li>
          <li>
            <a class="nav-link" href="#What_is_HTML">
              What is HTML
            </a>
          </li>
          <li>
            <a class="nav-link" href="#Anatomy_of_an_HTML_element">
              Anatomy of an HTML element
            </a>
          </li>
          <li>
            <a class="nav-link" href="#Nesting_elements">
              Nesting elements
            </a>
          </li>
          <li>
            <a class="nav-link" href="#Block_versus_inline_elements">
              Block versus inline elements
            </a>
          </li>
          <li>
            <a class="nav-link" href="#Empty_elements">
              Empty elements
            </a>
          </li>
        </ul>
      </nav>

      <main id="main-doc">
        <section class="main-section" id="Getting_started_with_HTML">
          <header>
            <h1>Getting started with HTML</h1>
          </header>

          <p>
            In this article we cover the absolute basics of HTML. To get you
            started, this article defines elements, attributes, and all the
            other important terms you may have heard. It also explains where
            these fit into HTML. You will learn how HTML elements are
            structured, how a typical HTML page is structured, and other
            important basic language features. Along the way, there will be an
            opportunity to play with HTML too!
          </p>

          <ul>
            <li>
              <strong>Prerequisites:</strong> Basic computer literacy, basic
              software installed, and basic knowledge of working with files.
            </li>
            <li>
              <strong>Objective:</strong> To gain basic familiarity with HTML,
              and practice writing a few HTML elements.
            </li>
          </ul>
        </section>

        <section class="main-section" id="What_is_HTML">
          <header>
            <h2>What is HTML</h2>
          </header>

          <p>
            HTML (Hypertext Markup Language) is a markup language that tells web
            browsers how to structure the web pages you visit. It can be as
            complicated or as simple as the web developer wants it to be. HTML
            consists of a series of elements, which you use to enclose, wrap, or
            mark up different parts of content to make it appear or act in a
            certain way. The enclosing tags can make content into a hyperlink to
            connect to another page, italicize words, and so on. For example,
            consider the following line of text:
          </p>

          <code>
            My cat is very grumpy
          </code>

          <p>
            If we wanted the text to stand by itself, we could specify that it
            is a paragraph by enclosing it in a paragraph (&lt;p&gt;) element:
          </p>

          <code>&lt;p&gt;My cat is very grumpy&lt;/p&gt;</code>

          <div class="note">
            <strong>Note:</strong> Tags in HTML are not case-sensitive. This
            means they can be written in uppercase or lowercase. For example, a
            &lt;title&gt; tag could be written as &lt;title&gt;, &lt;TITLE&gt;,
            &lt;Title&gt;, &lt;TiTlE&gt;, etc., and it will work. However, it is
            best practice to write all tags in lowercase for consistency and
            readability.
          </div>
        </section>

        <section class="main-section" id="Anatomy_of_an_HTML_element">
          <header>
            <h2>Anatomy of an HTML element</h2>
          </header>

          <p>
            Let's further explore our paragraph element from the previous
            section:
          </p>

          <img
            src="https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started/grumpy-cat-small.png"
            alt="Anatomy of an HTML element"
          />

          <p>The anatomy of our element is:</p>

          <ul>
            <li>
              <strong>The opening tag:</strong> This consists of the name of the
              element (in this example, p for paragraph), wrapped in opening and
              closing angle brackets. This opening tag marks where the element
              begins or starts to take effect. In this example, it precedes the
              start of the paragraph text.
            </li>
            <li>
              <strong>The content:</strong> This is the content of the element.
              In this example, it is the paragraph text.
            </li>
            <li>
              <strong>The closing tag:</strong> This is the same as the opening
              tag, except that it includes a forward slash before the element
              name. This marks where the element ends. Failing to include a
              closing tag is a common beginner error that can produce peculiar
              results.
            </li>
          </ul>

          <p>
            The element is the opening tag, followed by content, followed by the
            closing tag.
          </p>
        </section>

        <section class="main-section" id="Nesting_elements">
          <header><h2>Nesting elements</h2></header>

          <p>
            Elements can be placed within other elements. This is called
            nesting. If we wanted to state that our cat is very grumpy, we could
            wrap the word very in a &lt;strong&gt; element, which means that the
            word is to have strong(er) text formatting:
          </p>

          <code
            >&lt;p&gt;My cat is &lt;strong&gt;very&lt;/strong&gt;
            grumpy.&lt;/p&gt;</code
          >

          <p>
            There is a right and wrong way to do nesting. In the example above,
            we opened the p element first, then opened the strong element. For
            proper nesting, we should close the strong element first, before
            closing the p.
          </p>

          <p>The following is an example of the wrong way to do nesting:</p>

          <code
            >&lt;p&gt;My cat is &lt;strong&gt;very
            grumpy.&lt;/p&gt;&lt;/strong&gt;</code
          >

          <p>
            The
            <strong
              >tags have to open and close in a way that they are inside or
              outside one another</strong
            >. With the kind of overlap in the example above, the browser has to
            guess at your intent. This kind of guessing can result in unexpected
            results.
          </p>
        </section>

        <section class="main-section" id="Block_versus_inline_elements">
          <header><h2>Block versus inline elements</h2></header>

          <p>
            There are two important categories of elements to know in HTML:
            block-level elements and inline elements.
          </p>

          <ul>
            <li>
              Block-level elements form a visible block on a page. A block-level
              element appears on a new line following the content that precedes
              it. Any content that follows a block-level element also appears on
              a new line. Block-level elements are usually structural elements
              on the page. For example, a block-level element might represent
              headings, paragraphs, lists, navigation menus, or footers. A
              block-level element wouldn't be nested inside an inline element,
              but it might be nested inside another block-level element.
            </li>
            <li>
              Inline elements are contained within block-level elements, and
              surround only small parts of the document's content (not entire
              paragraphs or groupings of content). An inline element will not
              cause a new line to appear in the document. It is typically used
              with text, for example an &lt;a&gt; element creates a hyperlink,
              and elements such as &lt;em&gt; or &lt;strong&gt; create emphasis.
            </li>
          </ul>

          <p>Consider the following example:</p>

          <code>
            &lt;em&gt;first&lt;/em&gt;&lt;em&gt;second&lt;/em&gt;&lt;em&gt;third&lt;/em&gt;<br>
            &lt;p&gt;fourth&lt;/p&gt;&lt;p&gt;fifth&lt;/p&gt;&lt;p&gt;sixth&lt;/p&gt;
          </code>

          <p>
            &lt;em&gt; is an inline element. On the other hand, &lt;p&gt; is a
            block-level element. Each p element appears on a new line, with
            space above and below. (The spacing is due to default CSS styling
            that the browser applies to paragraphs).
          </p>

          <div class="note">
            <strong>Note:</strong> HTML5 redefined the element categories: see
            Element content categories. While these definitions are more
            accurate and less ambiguous than their predecessors, the new
            definitions are a lot more complicated to understand than block and
            inline. This article will stay with these two terms.
          </div>

          <div class="note">
            <strong>Note:</strong> The terms block and inline, as used in this
            article, should not be confused with the types of CSS boxes that
            have the same names. While the names correlate by default, changing
            the CSS display type doesn't change the category of the element, and
            doesn't affect which elements it can contain and which elements it
            can be contained in. One reason HTML5 dropped these terms was to
            prevent this rather common confusion.
          </div>

          <div class="note">
            <strong>Note:</strong> Find useful reference pages that include
            lists of block and inline elements. See Block-level elements and
            Inline elements.
          </div>
        </section>

        <section class="main-section" id="Empty_elements">
          <header><h2>Empty elements</h2></header>

          <p>
            Not all elements follow the pattern of an opening tag, content, and
            a closing tag. Some elements consist of a single tag, which is
            typically used to insert/embed something in the document. For
            example, the &lt;img&gt; element embeds an image file onto a page:
          </p>

          <code>
            &lt;img
            src="https://raw.githubusercontent.com/mdn/beginner-html-site/gh-pages/images/firefox-icon.png"&gt;
          </code>

          <div class="note">
            <strong>Note:</strong> Empty elements are sometimes called void
            elements.
          </div>

          <div class="note">
            <strong>Note:</strong> In HTML, there is no requirement to add a /
            at the end of an empty element's tag, for example: &lt;img
            src="images/cat.jpg" alt="cat" /&gt;. However, it is also a valid
            syntax and you may do this when you want your HTML to be valid XML
          </div>
        </section>
      </main>
    </div>
              
            
!

CSS

              
                /* User Story #15: My Technical Documentation page should use at least one media query. */

/* Import Open Sans Font */

@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');

/* Reset */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base styles */

h1, h2, h3, p, img, .note {
    margin-bottom: 1rem;
}

/* Typography */

body {
    font-family: 'Open Sans', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #111;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.2rem;
}

/* List styles */

ul, ol {
    margin-left: 2rem;
}

li {
    line-height: 1.75rem;
}

/* Code element */

code {
    font-family: 'Source Code Pro', monospace;
    display: block;
    background-color: #eee;
    padding: .5rem 1rem;
    margin: 1rem 0;
    border-radius: .5rem;
}

/* Page layout */

#page {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 1rem;
  padding: 1rem;
}

@media screen and (min-width: 900px) {
  #page {
    width: 90vw;
  }
}

@media screen and (min-width: 1600px) {
  #page {
    width: 80vw;
    margin: 0 auto;
  }
}

#navbar {
    width: 400px;
}

#main-doc {
    flex: 1;
}

@media screen and (max-width: 768px) {
    #navbar {
        flex: 1;
        display: none;
    }

    #main-doc {
        flex: 2;
    }
}

/* Notes */

.note {
  padding: 1rem;
  border-radius: .5rem;
  background: #9cf7;
  border: 1px solid #ccc;
  border-left: 5px solid #6af;
}

              
            
!

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