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

              
                <body>
  <div id="body-div">
  <nav id="navbar">
    <header>
      <h1> CSS Documentation </h1>
    </header>
  <div id="nav-div">
    <a href="#Introduction" class="nav-link">Introduction</a>
    <a href="#What_you_should_already_know" class="nav-link"> What you should already know </a>
    <a href="#CSS_Syntax" class="nav-link"> CSS Syntax </a>
    <a href="#Where_do_we_write_CSS?" class="nav-link"> Where do we write CSS? </a>
    <a href="#Selectors" class="nav-link"> Selectors </a>
    <a href="#Specificity_&_Hierarchy" class="nav-link"> Specificity & Hierarchy </a>
    <a href="#Comments" class="nav-link"> Comments </a>
    <a href="#Reference" class="nav-link"> Reference </a>
      <a class="mdn-link" href="https://developer.mozilla.org/en-US/docs/Web/CSS" target="_blank">More info on CSS</a>
    </div>
  </nav>
  <main id="main-doc">
    <section id="Introduction" class="main-section">
      <header>
        <h2>Introduction</h2>
      </header>
      <p> CSS (Cascading Style Sheets) is a styling language used to style webpages. </p>
      <ul>
        <li>It most commonly works with HTML.</li>
        <li>It dictates how HTML elements are displayed on screen, paper and other media.</li>
        <li>It is one of the core languages of the web.</li>
        <li>It can be used to style an individual letter or word or an entire website.</li>
      </ul>
    </section>
    <section id="What_you_should_already_know" class="main-section">
      <header>
        <h2>What you should already know</h2>
      </header>
      <p> Before learning CSS is it advisable to have some basic knowledge.</p>
      <ul>
        <li> A rudimentary understanding of the internet and World Wide Web. </li>
        <li> An understanding of HTML and how to use it. </li>
      </ul>
    </section>
    <section id="CSS_Syntax" class="main-section">
      <header>
        <h2>CSS Syntax</h2>
      </header>
      <p> Below is an example of a CSS rule or ruleset in which we choose the HTML element we wish to style, called the selector. In this case a paragraph.</p>
      <p>Then inside curly braces we declare which styles we wish to apply to the paragraph, These are called declarations. In this case a red color and a bold font. Each declaration ends with a semicolon.</p>
        <code>
         p {<br>
         color:red;<br>
         font-weight:bold;<br>
         }
        </code>
    </section>
    <section id="Where_do_we_write_CSS?" class="main-section">
      <header>
        <h2>Where do we write CSS?</h2>
      </header>
      <p> CSS can be written in three places. </p>
      <p class="wherep"> <b>1</b> - Inline CSS where declarations are written within the HTML. This is generally not used as it quickly becomes messy. It is usually advisable to keep HTML & CSS separate.</p>
        <code>
          &lt;p style="color:red;"&gt;
      </code>
      <p class="wherep whereptwo"> <b>2</b> - Internal within style tags, within the head section of the HTML document. This might be used on a very small website.</p>

      <p class="wherep"> <b>3</b> - Externally on a CSS stylesheet. This is the most commonly used method. A link tag is required for this method, placed within the head section.</p>
        <code>
         &lt;link rel="stylesheet" href="styles.css"&gt;
        </code>
      <p> The syntax for methods 2 & 3 is actually the same (see CSS Syntax). For method 1 the CSS declaration is placed within the chosen HTML tag.</p>
    </section>
    <section id="Selectors" class="main-section">
      <header>
        <h2>Selectors</h2>
      </header>
      <p> A CSS selector targets the HTML element or elements you wish to style. Each CSS rule starts with a selector or multiple selectors to target several different elements with the same styling.</p>
      <p> We saw in CSS syntax how paragraph elements can be targeted for styling. That particular selector would target all paragraph elements with the same styling. Below we see how multiple elements can be targeted at the same time by separating them with commas. </p>
        <code>
          h1, h2, h3 {<br>
          color:red;<br>
          }<br>
        </code>
      <p> In the example above all headings h1 h2 & h3 would be colored red.</p>
      <p> There are times however when we want to target individual elements rather than every element, such as an individual heading. The most common way to do this is with ID's and Classes which you should have covered in part whilst learning HTML.</p>
      <p> Below we see an example of how a heading h1 element can be individually targeted by using an ID. This is done by using # before the ID name. </p>
        <code>
          #heading-main {<br>
          font-size:30px;<br>
          }<br>
        </code>
      <p> Next we will see how to target an element by using a class. This is done by using . before the class name. </p>
        <code>
          .sub-heading {<br>
          color:red;<br>
          }<br>
        </code>
    </section>
    <section id="Specificity_&_Hierarchy" class="main-section">
      <header>
        <h2> Specificity & Hierarchy </h2>
      </header>
      <p> Where there are multiple conflicting rules which target an element CSS has rules it follows to decide which has priority.</p>
      <p> For example if you target an element with the color red, then below it target the same element with color blue. The blue will be given priority and the red above will be ignored.</p>
      <p> There are many rules governing which selectors take priority. Classes and ID's have a higher priority than a standard element with ID's taking priority above classes. </p>
    </section>
    <section id="Comments" class="main-section">
      <header>
        <h2> Comments </h2>
      </header>
      <p> As you will have learned whilst studying HTML, comments are an important and useful tool to aid the developer. They help to explain code particularly when comming back to edit at a later date. </p>
      <p> They do not appear on the browser and are solely for the developers reference. They are written slightly differently to an HTML comment and are obviously placed with the CSS not HTML. A CSS comment will not work amongst the HTML and vice versa. </p>
      <p> CSS comments start with /* and end with */. Example below. </p>
        <code>
          p {<br>
          color:green;<br>
          /*background:red;*/<br>
          }<br>
        </code>
      <p> In the example above the comment was used just for the background red declaration but as with HTML comments they can also be used to comment out multiple lines at once. </p>
    </section>
    <section id="Reference" class="main-section">
      <header>
        <h2> Reference </h2>
      </header>
      <ul>
        <li>Information taken from w3schools and MDN</li>
      </ul>
      <div id="top">
      <a href="#body-div" id="top-link" title="top of page">top</a>
      </div>
    </section>
  </main>
  </div>
</body>
              
            
!

CSS

              
                * {
  box-sizing:border-box;
  padding:0px;
  margin:0px;
}
#body-div {
  display:grid;
  grid-template-columns:300px 1fr;
  grid-template-areas:"nav mai";
  max-width:100vw;
  font-family:arial;
}
#navbar {
  --gray:rgb(212,222,222);
  position:fixed;
  top:0px;
  grid-area:nav;
  width:300px;
}
#nav-div {
  overflow:auto;
  height:82vh;
}
#navbar h1 {
  font:600 26px arial; 
}
.mdn-link {
  border-bottom:2px solid black;
}
#navbar header {
  padding:32px 18px;
  outline:1px solid black;
}
a[href="#Introduction"]{
  border-top:2px solid black;
}
#navbar a {
  display:block;
  padding:18px 13px 18px 18px;
  outline:1px solid black;
  text-decoration:none;
  color:black;
  background:var(--gray);
  font:400 18px arial;
}
#navbar a:hover {
  background:white;
}
#main-doc {
  grid-area:mai;
  width:100%;
  padding:15px 30px 15px 45px;
  border-left:2px solid black;
}
#main-doc h2 {
  font:600 22px arial;
  padding:35px 0px 20px 0px;
}
#main-doc [id] {
  scroll-margin-top:1.3rem;
}
#main-doc li {
  padding:4px 0px;
}
#main-doc ul {
  padding:18px;
}
#main-doc p {
  padding:5px 0px;
}
.wherep {
  text-indent:20px;
}
.whereptwo {
  margin-bottom:0px;
}
code {
  display:block;
  font:400 18px arial;
  padding:20px 6% 20px 8%;
  color:rgb(0,0,133);
}
#Reference li {
  padding:0px 18px 30px 18px;
}
#Reference ul {
  padding-top:0px;
}
#top, #top-link {
  text-decoration:none;
  text-align:center;
  color:black;
  font-weight:600;
}
#top-link:hover {
  color:rgb(0,0,193);
}
@media (max-height:450px) {
  #nav-div {
    height:75vh;
  }
}
@media (max-width:650px) {
  #body-div {
    grid-template-columns:1fr;
    grid-template-areas:"nav"
                        "mai";
  }
  #navbar a {
    padding:17px 7% 17px 8%;
    font:600 16px arial;
  }
  #navbar {
    position:static;
    width:100%;
  }
  code {
    padding:15px 7%;
  }
  #navbar h1 {
    font-size:24px;
  }
  #navbar header {
    text-align:center;
  }
  #main-doc {
    width:100%;
    padding:10px 30px 15px 45px;
    border:0px;
  }
}
  

              
            
!

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