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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <!-- 

Hello Camper!

Please read the README below in the JS Editor before beginning. Feel free to delete this message once you have read it. Good luck and Happy Coding! 

- The freeCodeCamp Team 

-->
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>FCC-Technical Document Project</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../fcc-technical-document/styles.css" type="text/css">
        <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap" rel="stylesheet"> 
    </head>
    <body>
        <!--Navigation Section-->
        
            <nav id="navbar">
                <header>The Document Object Model (DOM)</header>
                <ul>
                    <li><a class="nav-link" href="#Introduction_to_the_DOM">Introduction to the DOM</a></li>
                    <li><a class="nav-link" href="#What_is_the_DOM?">What is the Dom?</a></li>
                    <li><a class="nav-link" href="#DOM_and_Javascript">DOM and Javascript</a></li>
                    <li><a class="nav-link" href="#Accessing_the_DOM">Accessing the DOM</a></li>
                    <li><a class="nav-link" href="#DOM_Interfaces">DOM Interfaces</a></li>
                    <li><a class="nav-link" href="#Reference">Reference</a></li>
                </ul>
            </nav>

        <!--First Section-->    
        <main id="main-doc">
            <section class="main-section" id="Introduction_to_the_DOM">
                <header>Introduction to the DOM</header>
                <article>
                    <p>The Document Object Model (DOM) is the data representation of the objects that comprise the structure and content of a document on the web. In this guide, we'll briefly introduce the DOM. We'll look at how the DOM represents an HTML or XML document in memory and how you use APIs to create web content and applications.</p>
                    <p>Below is an example of a DOM Tree Model:</p>
                    <figure><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/DOM-model.svg/1200px-DOM-model.svg.png" alt="Example of a DOM tree"> <figcaption>DOM Model</figcaption></figure>
                </article>
            </section>


         <!--Second Section-->   
            <section class="main-section" id="What_is_the_DOM?">
               <header>What is the DOM?</header>
               <article>
                       <ul>
                           <li>The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects. That way, programming languages can connect to the page.</li>
                           <li>A Web page is a document. This document can be either displayed in the browser window or as the HTML source. But it is the same document in both cases. The Document Object Model (DOM) represents that same document so it can be manipulated. The DOM is an object-oriented representation of the web page, which can be modified with a scripting language such as JavaScript.</li>
                           <li>The W3C DOM and WHATWG DOM standards are implemented in most modern browsers. Many browsers extend the standard, so care must be exercised when using them on the web where documents may be accessed by various browsers with different DOMs.</li>
                           <li>For example, the standard DOM specifies that the querySelectorAll method in the code below must return a list of all the <code>&lt;p&gt;</code> elements in the document:
                            <p>
                                <code>
                                   const paragraphs = document.querySelectorAll("p");
                                   // paragraphs[0] is the first &lt;p&gt; element
                                   // paragraphs[1] is the second &lt;p&gt; element, etc. alert(paragraphs[0].nodeName);
                               </code>
                            </p> 
                            </li>
                            <li> All of the properties, methods, and events available for manipulating and creating web pages are organized into objects (for example, the document object that represents the document itself, the table object that implements the special HTMLTableElement DOM interface for accessing HTML tables, and so forth). This documentation provides an object-by-object reference to the DOM.</li>
                            <li>The modern DOM is built using multiple APIs that work together. The core DOM defines the objects that fundamentally describe a document and the objects within it. This is expanded upon as needed by other APIs that add new features and capabilities to the DOM. For example, the HTML DOM API adds support for representing HTML documents to the core DOM.</li>
                       </ul>
               </article>
            </section>

        <!--Third Section-->
            <section class="main-section" id="DOM_and_Javascript">
                <header>DOM and Javascript</header>
                <article>
                    <p>The short example above, like nearly all of the examples in this reference, is JavaScript. That is to say, it's written in JavaScript, but it uses the DOM to access the document and its elements. The DOM is not a programming language, but without it, the JavaScript language wouldn't have any model or notion of web pages, HTML documents, XML documents, and their component parts (e.g. elements). Every element in a document—the document as a whole, the head, tables within the document, table headers, text within the table cells—is part of the document object model for that document, so they can all be accessed and manipulated using the DOM and a scripting language like JavaScript.</p>
                    <p>In the beginning, JavaScript and the DOM were tightly intertwined, but eventually, they evolved into separate entities. The page content is stored in the DOM and may be accessed and manipulated via JavaScript, so that we may write this approximative equation: API = DOM + JavaScript</p>
                    <p>The DOM was designed to be independent of any particular programming language, making the structural representation of the document available from a single, consistent API. Though we focus exclusively on JavaScript in this reference documentation, implementations of the DOM can be built for any language, as this Python example demonstrates:</p>
                    <p>
                        <code># Python DOM example
                        import xml.dom.minidom as m
                        doc = m.parse(r"C:\Projects\Py\chap1.xml")
                        doc.nodeName # DOM property of document object
                        _list = doc.getElementsByTagName("para")</code>
                    </p>
                </article>
            </section>

        <!--Fourth Section-->
            <section class="main-section" id="Accessing_the_DOM">
                <header>Accessing the DOM</header>
                <article>
                    <p>You don't have to do anything special to begin using the DOM. Different browsers have different implementations of the DOM, and these implementations exhibit varying degrees of conformance to the actual DOM standard (a subject we try to avoid in this documentation), but every web browser uses some document object model to make web pages accessible via JavaScript.</p>
                    <p>When you create a script–whether it's inline in a <code id="inline">&lt;script&gt;</code> element or included in the web page by means of a script loading instruction–you can immediately begin using the API for the document or window elements to manipulate the document itself or to get at the children of that document, which are the various elements in the web page. Your DOM programming may be something as simple as the following, which displays an alert message by using the alert() function from the window object, or it may use more sophisticated DOM methods to actually create new content, as in the longer example below.</p>
                    <p>This following JavaScript will display an alert when the document is loaded (and when the whole DOM is available for use):</p>
                    <p>
                        <code>
                            &lt;body onload="window.alert('Welcome to my home page!');"&gt;&lt;/body&gt;
                        </code>
                    </p>
                </article>
            </section>

        <!--Fifth Section-->

            <section class="main-section" id="DOM_Interfaces">
                <header>DOM Interfaces</header>
                <article>
                    <p>This guide is about the objects and the actual things you can use to manipulate the DOM hierarchy. There are many points where understanding how these work can be confusing. For example, the object representing the HTML form element gets its name property from the HTMLFormElement interface but its className property from the HTMLElement interface. In both cases, the property you want is in that form object.</p>
                    <p>But the relationship between objects and the interfaces that they implement in the DOM can be confusing, and so this section attempts to say a little something about the actual interfaces in the DOM specification and how they are made available.</p>
                    <p class="small-header">Interfaces and Objects</p>
                    <p>Many objects borrow from several different interfaces. The table object, for example, implements a specialized HTMLTableElement interface, which includes such methods as createCaption and insertRow. But since it's also an HTML element, table implements the Element interface described in the DOM Element Reference chapter. And finally, since an HTML element is also, as far as the DOM is concerned, a node in the tree of nodes that make up the object model for an HTML or XML page, the table object also implements the more basic Node interface, from which Element derives.</p>
                    <p>When you get a reference to a table object, as in the following example, you routinely use all three of these interfaces interchangeably on the object, perhaps without knowing it.</p>
                    <p>
                        <code>
                            const table = document.getElementById("table");
                            const tableAttrs = table.attributes; // Node/Element interface
                            for (let i = 0; i &lt;tableAttrs.length; i++) {
                            // HTMLTableElement interface: border attribute
                            if(tableAttrs[i].nodeName.toLowerCase() == "border")
                                table.border = "1";
                            }
                            // HTMLTableElement interface: summary attribute
                            table.summary = "note: increased border";
                        </code>
                    </p>
                </article>
            </section>
            
        <!--Reference Section-->

            <section class="main-section" id="Reference">
                <header>Reference</header>
                <p>All information provided by <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction">MDN Web Docs</a>.</p>
            </section>

        </main>
    </body>
</html>
              
            
!

CSS

              
                /*Body*/

html{
    font-size: 16px;
    font-family: 'DM Sans', sans-serif;
    line-height: 1.5;
}

/*Navigation Bar*/

#navbar{
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: rgb(212, 212, 212);
    overflow: hidden;
    padding-top: 2%;
    width: 25%;
    height: 100%;
    box-shadow: 2px 2px 5px black;
}

/*added 7/20/2021*/
:root{
  scroll-behavior: smooth;
}

a {
transition: 0.3s ease-in-out;
color: black;
text-decoration: none;
}
a:hover {
transform: scale(1.2);
text-shadow: 2px 2px 5px black;
}

/*end of new addition*/

.main-section{
    margin: 3%;
}

.main-section header{
    font-size: 1.75rem;
    text-align: center;
    font-weight:bolder;
}

#navbar header{
    font-size: 1.75rem;
    font-weight: bolder;
    text-align: center;
}

#navbar ul{
    height: 65%;
    padding: 0;
}

#navbar li{
    list-style: none;
    border-top: 2.5px solid;
    width: 100%;
    padding: 1.5rem;
}

/*Main Section*/

main{
    margin-left: 25%;
}

img{
    max-width: 50%;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

figcaption{
    width: 30rem;
    font-size: 1.10rem;
    text-align: center;
    margin: 0.50rem auto;
    border-top: 1px solid black;
    
}

.small-header{
    font-size: 1.25rem;
    font-weight: bold;
}

#Reference{
    text-align: center;
}

p > code{
    display: block;
    background-color: rgb(230, 221, 221);
    width: 35rem;
    white-space: pre-line;
    word-wrap: normal;
    margin: 1% auto;
    padding: 1rem 2rem;
}

#inline{
    display: inline;
    padding: 0rem;
}

/*Media Querie(s)*/
@media screen and (max-width: 794px){
    #navbar{
        position: absolute;
        top:0;
        padding: 0;
        margin: 0;
        width: 100%;
        max-height: 250px;
        border: none;
        z-index: 1;
        display: none;
    }
    #main-doc{
        position: relative;
        margin-top: 0px;
        margin-left: 0px;
    }
    p > code{
     max-width: 95%;
    }
  
  figcaption{
    border: none;
    display: none;
  }
}
              
            
!

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