Navbar & sizing issues - Build a Technical Documentation Page

I have a couple of issues one with the test and one with formatting, I know I have yet to add a media query but will do that when have these other bits sorted.

  1. The test is saying I must have the same amount of .nav-link as I do of .main-section in the HTML I have been through it and through it and can only find 10 of each, have also used a find function and it can find 10 of each also? Have checked each section tags and they are closed, I know its right in front of me but for the life of me I can’t see it.

  2. My content is not shrinking down when I’m resizing the window instead it adds scroll bars which when you then scroll left-right the main content goes behind the navbar same when you click a nav link.

Thank you!

Your code so far

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="stylesheet" href="styles.css"/>
    <title>HTML: Basics Document</title>
  </head>

  <div class="container">
  <body>

<!-- Navigation -->
    <div class="nav-container">
    <nav id="navbar">
      <header>HTML Basics Document</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="#anatomy_of_html_elements">Anatomy of HTML elements</a>
          </li>
          <li><a class="nav-link"  href="#nesting_elements">Nesting elements</a>
          </li>
          <li><a class="nav-link"  href="#empty_elements">Empty elements</a>
          </li>
          <li><a class="nav-link"  href="#anatomy_of_html_documents">Anatomy of HTML documents</a>
          </li>
          <li><a class="nav-link"  href="#images_in_html">Images in HTML</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="#reference">Reference</a>
          </li>
        </ul>
    </nav>
    </div>
<!-- End: Navigation -->

 
  <main id="main-doc">    

<!-- Introduction -->

      <section id="introduction" class="main-section">
        <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> 

<!-- End: introduction -->


<!-- What is HTML -->

      <section id="what_is_html" class="main-section">
        <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:
            </p>
            <p>
            <code class="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>
            <p>
            <code class="code">&ltp&gt;my cat is very grumpy&lt&frasl;p&gt</code>
            </p>
        </article>
      </section>   

<!-- End : What is HTML -->


<!-- Anatomy of HTML elements -->
      <section id="anatomy_of_html_elements" class="main-section">
        <header>Anatomy of HTML elements</header>
        <article>
          <p>
            Let's explore this paragraph element a bit further.
          </p>  
          <p><img src="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics/grumpy-cat-small.png" alt="An example of html code with paragraph elements"/>
          </p>
          <p>
            The main parts of our element are as follows:
            <ol class="anatomy-list">
              <li><strong>The opening tag:</strong> This consists of the name of the element (in this case, p), wrapped in opening and closing angle brackets. This states where the element begins or starts to take effect — in this case where the paragraph begins.</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 states where the element ends — in this case where the paragraph ends. Failing to add a closing tag is one of the standard beginner errors and can lead to strange results.</li>
              <li><strong>The content:</strong> This is the content of the element, which in this case, is just text.</li>
              <li><strong>The element:</strong> The opening tag, the closing tag, and the content together comprise the element.</li>
            </ol>
          </p>
          <p>
            Elements can also have attributes that look like the following:
          </p>
          <p>
            <img src="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics/grumpy-cat-attribute-small.png" alt="an example of html code showing the attribute section" />
          </p>
          <p>
            Attributes contain extra information about the element that you don't want to appear in the actual content. Here, class is the attribute name and editor-note is the attribute value. The class attribute allows you to give the element a non-unique identifier that can be used to target it (and any other elements with the same class value) with style information and other things.
          </p>
          <p>
            An attribute should always have the following:
            <ol class="anatomy-list">
              <li>A space between it and the element name (or the previous attribute, if the element already has one or more attributes).</li>
              <li>The attribute name followed by an equal sign.</li>
              <li>The attribute value wrapped by opening and closing quotation marks.</li>
            </ol>
          </p>
        </article>
      </section>

<!-- End: Anatomy of HTML elements -->


<!-- Nesting elements -->

      <section id="nesting_elements" class="main-section">
        <header>Nesting Elements</header>
        <article>
          <p>
            You can put elements inside other elements too — this is called nesting. If we wanted to state that our cat is <strong>very</strong> grumpy, we could wrap the word "very" in a &ltstrong&gt; element, which means that the word is to be strongly emphasized:
          </p>
          <p>
            <code class="code">&ltp&gt;my cat is &ltstrong&gt;very&lt&frasl;strong&gt; grumpy&lt&frasl;p&gt</code>
          </p>
          <p>
            You do however need to make sure that your elements are properly nested. In the example above, we opened the &ltp&gt; element first, then the &ltstrong&gt; element; therefore, we have to close the &ltstrong&gt; element first, then the &ltp&gt; element. The following is incorrect:
          </p>
          <p>
            <code class="incorrect_code">&ltp&gt;my cat is &ltstrong&gt;very grumpy&lt&frasl;p&gt&lt&frasl;strong&gt;</code>
          </p>
          <p>
            The elements have to open and close correctly so that they are clearly inside or outside one another. If they overlap as shown above, then your web browser will try to make the best guess at what you were trying to say, which can lead to unexpected results. So don't do it!
          </p>
        </article>
      </section>

<!-- End: Nesting elements -->

<!-- Empty elements -->

      <section id="empty_elements" class="main-section">
        <header>Empty elements</header>
        <article>
          <p>
            Some elements have no content and are called empty elements. Take the &ltimg&gt element that we already have in our HTML page:
          </p>
          <p>
            <code class="code">&ltimg src="images/firefox-icon.png" alt="My test image" &frasl;&gt</code>
          </p>
          <p>
            This contains two attributes, but there is no closing &lt&frasl;img&gt tag and no inner content. This is because an image element doesn't wrap content to affect it. Its purpose is to embed an image in the HTML page in the place it appears.
          </p>
        </article>
      </section>

<!-- End: Empty elements -->


<!-- Anatomy of HTML doc -->

      <section id="anatomy_of_html_documents" class="main-section">
        <header>Anatomy of HTML Documents</header>
        <article>
          <p>
            That wraps up the basics of individual HTML elements, but they aren't handy on their own. Now we'll look at how individual elements are combined to form an entire HTML page. Let's revisit the code we put into our <em>index.html</em> example:
          </p>
          <p>
            <pre><code>
&lt!DOCTYPE html&gt
&lthtml lang="en-US"&gt
  &lthead&gt
    &ltmeta charset="utf-8" &frasl;&gt
    &ltmeta name="viewport" content="width=device-width" &frasl;&gt
    &lttitle&gtMy test page&lt&frasl;title&gt
  &lt&frasl;head&gt
  &ltbody&gt
    &ltimg src="images/firefox-icon.png" alt="My test image" frasl;&gt
  &lt&frasl;body>
&lt&frasl;html&gt
            </code></pre>
          </p>
          <p>
            Here, we have the following:
            <ul>
              <li><strong>&lt!DOCTYPE html&gt</strong> — doctype. It is a required preamble. In the mists of time, when HTML was young (around 1991/92), doctypes were meant to act as links to a set of rules that the HTML page had to follow to be considered good HTML, which could mean automatic error checking and other useful things. However these days, they don't do much and are basically just needed to make sure your document behaves correctly. That's all you need to know for now.</li>
              <li><strong>&lthtml&gt&lt&frasl;html&gt</strong> — the &lthtml&gt element. This element wraps all the content on the entire page and is sometimes known as the root element. It also includes the lang attribute, setting the primary language of the document.</li>
              <li><strong>&lthead&gt&lt&frasl;head&gt</strong> — the &lthead&gt element. This element acts as a container for all the stuff you want to include on the HTML page that isn't the content you are showing to your page's viewers. This includes things like keywords and a page description that you want to appear in search results, CSS to style our content, character set declarations, and more.</li>
              <li><strong>&ltmeta charset="utf-8" &frasl;&gt</strong> — This element sets the character set your document should use to UTF-8 which includes most characters from the vast majority of written languages. Essentially, it can now handle any textual content you might put on it. There is no reason not to set this and it can help avoid some problems later on.</li>
              <li><strong>&ltmeta name="viewport" content="width=device-width" &frasl;&gt</strong> — This viewport element ensures the page renders at the width of viewport, preventing mobile browsers from rendering pages wider than the viewport and then shrinking them down.</li>
              <li><strong>&lttitle&gtMy test page&lt&frasl;title&gt</strong> — the &lttitle&gt element. This sets the title of your page, which is the title that appears in the browser tab the page is loaded in. It is also used to describe the page when you bookmark/favorite it.</li>
              <li><strong>&ltbody&gt&lt&frasl;body&gt</strong> — the &ltbody&gt element. This contains all the content that you want to show to web users when they visit your page, whether that's text, images, videos, games, playable audio tracks, or whatever else.</li>
            </ul>
          </p>
        </article>
      </section>  

<!-- Anatomy of HTML doc -->

<!-- Images in HTML -->

      <section id="images_in_html" class="main-section">
        <header>Images in HTML</header>
        <article>
          <p>
            Let's turn our attention to the &ltimg&gt element again:
          </p>
          <p>
            <code>
              &ltimg src="images/firefox-icon.png" alt="My test image" &frasl;&gt
            </code>
          </p>
          <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 the alt attribute, you specify descriptive text for users who cannot see the image, possibly because of the following reasons:
            <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>
            <div class="broken-image">
            <img src="an_image_location" alt="My broken test image" />
            </div>
          <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 would be text describing what image should have been there.
          </p>
        </article>
      </section>  

<!-- End: Images in HTML -->

<!-- Marking up text -->

      <section id="marking_up_text" class="main-section">
        <header>Marking up text</header>
        <article>
          <header class="sub-head">Headings</header> 
            <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, &lth1&gt - &lth6&gt, although you'll commonly only use 3 to 4 at most:
            </p>
            <p>
              <pre><code>
&lt!-- 4 heading levels: --&gt

&lth1&gtMy main title&lt&frasl;h1&gt

&lth2&gtMy top level heading&lt&frasl;h2&gt

&lth3&gtMy subheading&lt&frasl;h3&gt

&lth4&gtMy sub-subheading&lt&frasl;h4&gt
              </pre></code>
            </p>
          <header class="sub-head">Paragraphs</header>
            <p>
              As explained above, &ltp&gt elements are for containing paragraphs of text; you'll use these frequently when marking up regular text content:
            </p>
            <p>
              <code class="code">
                &ltp&gtThis ia a single paragraph&lt&frasl;p&gt
              </code>
            </p>
          <header class="sub-head">Lists</header>
            <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:
                <ol>
                  <li><strong>Unordered lists</strong> are for lists where the order of the items doesn't matter, such as a shopping list. These are wrapped in a &ltul&gt element.</li>
                  <li><strong>Ordered lists</strong> are for lists where the order of the items does matter, such as a recipe. These are wrapped in an &ltol&gt element.</li> 
                </ol>
            </p>
            <p>
              Each item inside the lists is put inside an &ltli&gt (list item) element.
            </p>
            <p>
              For example, if we wanted to turn the part of the following paragraph fragment into a list
            </p>
            <p>
              <pre><code>
&ltp&gt
  At Mozilla, we're a global community of technologists, thinkers, and builders

  working together…
&lt&frasl;p&gt
              </code></pre>
            </p>
            <p>
              We could modify the markup to this
            </p>
            <p>
              <pre><code>
&ltp&gtAt Mozilla, we're a global community of&lt&frasl;p&gt

&ltul&gt
  &ltli&gttechnologists&lt&frasl;li&gt
  &ltli&gtthinkers&lt&frasl;li&gt
  &ltli&gtbuilders&lt&frasl;li&gt
&lt&frasl;ul&gt

&ltp&gtworking together…&lt&frasl;p&gt
              </code></pre>
            </p>
        </article>
      </section> 

<!-- End: Marking up text -->  

<!-- Links -->

      <section id="links" class="main-section">
        <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 — &lta&gt — "a" being the short form for "anchor". To make text within your paragraph into a link, follow these steps:
            <ol>
              <li>Choose some text. We chose the text "Mozilla Manifesto".</li>
              <li>Wrap the text in an &lta&gt element</li>
              <li>Give the &lta&gt element an href attribute</li>
              <li>Fill in the value of this attribute with the web address that you want the link to:</li>
            </ol>
          </p>
          <p>
            <code class="code">
              &lta href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto&lt&frasl;a&gt
            </code>
          </p>
          <p>
            You might get unexpected results if you omit the <strong>https://</strong> or <strong>http://</strong> 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>   

<!-- End: Links -->

<!-- Reference -->

<section class="reference" id="reference" class="main-section">
        <header>Reference</header>
        <article>
          <p>
            <ul>
            <li>This information has been gathered from <a class="ref-link" target="blank" href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics">MDN Webdocs</a> and used to compile this HTML page as part of a <a class="ref-link" target="blank" href="https://www.freecodecamp.org">freeCodeCamp</a> project.</li>
            </ul>
          </p>
        </article>
      </section> 

<!-- End: Reference -->
      </main>
     </body>
    </div>
  
</html>


<!-----/* ------ CSS -Stylesheet --------- */------->

*, *::before, *::after {
  margin: 0;
  padding: 0;
  font-family: tahoma;
  box-sizing: border-box;
}


.nav-container {
  display: block;
  position: fixed;
  width: 300px;
  min-width: 290px;
  height: 100%;
  top: 0;
  left: 0;
  border-right: grey solid 2px;
}


#navbar header {
  text-align: left;
  padding: 10px 0 5px 10px;
  border-bottom: grey solid 2px;
}


#navbar ul {
  list-style: none;
  margin-top: 10px;
}


#navbar li {
  margin-bottom: 20px;
  border-bottom: grey solid 2px;
  padding: 4px;
  text-align: left;
  font-size: 1.1em;  
  position: relative;
}


.nav-link {
  text-decoration: none;
}


.nav-link:visited {
  color: black;
}


.nav-link:hover,
.nav-link:focus {
  color: grey;
}


#main-doc {
  display: block;
  position: absolute;
  top: 0;
  left: 320px;
  margin: 0 auto;
  width: 100%;
  max-width: 65em;
}


header {
  margin-bottom: 10px;
  margin-top: 25px;
  font-size: 1.8em;
}


p {
  margin-bottom: 15px;
  line-height: 1.5;
}


article li {
  margin-bottom: 8px;
  margin-left: 2em;
  line-height: 1.5;
}


img {
  max-width: 100%;
}

.broken-image {
  padding: 25px;
}


pre, .code {
  display: inline-block;
  background: hsl(0, 0%, 94%);
  margin-left: 1em;
  margin-bottom: 1em;
  padding: 5px;
  padding-left: 25px;
  padding-right: 25px;
  border-radius: 5px;
}


#reference a {
  text-decoration: none;
}


.reference a:visited {
  color: black;
}


.reference a:hover,
.reference a:focus {
  color: grey;
}

  

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.33

Challenge: Technical Documentation Page - Build a Technical Documentation Page

Link to the challenge:

I am concerned by the fact that you have a div outside of your body that you may have a lot of HTML syntax/format coding issues.

So apart from fixing this 1 issue I saw, please put your code through an online HTML validator and fix all the errors you see (you have to pass it through multiple times to catch everything).

here’s one validator I use

(if you need help understanding the errors let us know)

Another note on your links that you will need to fix:

Make sure they match down to the capitalization as well.
(So here the link should be #Marking_up_text

And above the same, the id should be #Marking_up_text

The exercise mentions this example to call out this requirement:

(e.g. The section that contains the header “JavaScript and Java” should have a corresponding id="JavaScript_and_Java" )

Thanks, I added the div to try and correct some bits, it didn’t do as I expected but that is probably as you say because it outside of the body. I will rectify/remove this div.

I must have missed the capitals in the example, will get this changed also.

I’ll correct these bits and run it through the validation tool, didn’t know this was a thing so super helpful thanks. Do you just run it through until it comes out with no errors?

I will let you know how I get on with the errors thrown up by the validator. :+1:

yes in my case I just run it until no errors remain (warning are less important).
However, you may still be able to pass the fCC challenge with errors in the HTML. So it is up to you to decide on how far you want to go.

1 Like

Perfect, thanks.

Will prob be tomorrow now but will post back in here and update the code when its done.

1 Like

I ran the code through the validator, very helpful, fixed all the errors and warnings (apart from warnings about headings in sections and articles as the headings are in header elements). Learned that code and list elements shouldn’t be in paragraphs I think I knew that just messed up when writing it out and used the paragraphs like a section/container type thing. :roll_eyes: :person_facepalming:

Changed up some of the CSS and HTML, the tests are passing (except media query) but am aware I need to add that so that’s great. The content is also shrinking down when reducing window size which is also great.

The content only shrinks down to a certain width then the scroll bar appears and allows you to scroll across at which point the main content goes behind the navbar, have attempted to add min width on this but doesn’t seem to change can this be resolved, or should this be the point that the media query kicks in and rearranges for smaller screens?

Also when adjusting the window height, the navbar gets covered and you can’t see some of the links

Code below>

How can I post the HTML again it went a bit nuts when I just did it?

CSS

*, *::before, *::after {
  margin: 0;
  padding: 0;
  font-family: tahoma;
  box-sizing: border-box;
}


.nav-container {
  display: block;
  position: fixed;
  width: 300px;
  min-width: 290px;
  height: 100%;
  top: 0;
  left: 0;
  border-right: grey solid 2px;
}


#navbar header {
  text-align: left;
  padding: 10px 0 5px 10px;
  border-bottom: grey solid 2px;
}


#navbar ul {
  list-style: none;
  margin-top: 20px;
}


#navbar li {
  margin-bottom: 20px;
  border-bottom: grey solid 2px;
  padding: 4px;
  text-align: left;
  font-size: 1.1em;  
  position: relative;
}


.nav-link {
  text-decoration: none;
  color:black;
}


.nav-link a:visited {
  color: black;
}


.nav-link:hover,
.nav-link:focus {
  color: grey;
}



#main-doc {
  display: block;
  position: absolute;
  top: 0;
  left: 320px;
  margin: 0 auto;
  width: auto;
  min-width: 300px;
}


#main-doc ol {
  margin-bottom: 30px;
}


#main-doc ul {
  margin-bottom: 30px;
}


header {
  margin-bottom: 10px;
  margin-top: 40px;
  font-size: 1.8em;
}


p {
  margin-bottom: 20px;
  line-height: 1.5;
}


article li {
  margin-bottom: 8px;
  margin-left: 2em;
  line-height: 1.5;
}


img {
  max-width: 80%;
  margin-bottom: 15px;
}

.broken-image {
  padding: 25px;
}


pre, .code {
  display: inline-block;
  background: hsl(0, 0%, 94%);
  margin-left: 1em;
  margin-bottom: 20px;
  padding: 5px;
  padding-left: 25px;
  padding-right: 25px;
  border-radius: 5px;
}

.incorrect-code {
  display: inline-block;
  background: hsl(0, 89%, 80%);
  margin-left: 1em;
  margin-bottom: 1em;
  padding: 5px;
  padding-left: 25px;
  padding-right: 25px;
  border-radius: 5px;
}


#Reference a {
  text-decoration: none;
  color: black;
}


#Reference a:visited {
  color: black;
}


#Reference a:hover,
#Reference a:focus {
  color: grey;
}

you have to put the code inside a code block. here are instructions to help you do that.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

Updated HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
    <title>HTML: Basics Document</title>
  </head>
  <body>

<!-- Navigation -->
    <div class="nav-container">
    <nav id="navbar">
      <header>HTML Basics Document</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="#Anatomy_of_HTML_elements">Anatomy of HTML elements</a>
          </li>
          <li><a class="nav-link"  href="#Nesting_elements">Nesting elements</a>
          </li>
          <li><a class="nav-link" href="#Empty_elements">Empty elements</a>
          </li>
          <li><a class="nav-link" href="#Anatomy_of_HTML_documents">Anatomy of HTML documents</a>
          </li>
          <li><a class="nav-link" href="#Images_in_HTML">Images in HTML</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="#Reference">Reference</a>
          </li>
        </ul>
    </nav>
    </div>
<!-- End: Navigation -->

 
  <main id="main-doc">    

<!-- Introduction -->

      <section id="Introduction" class="main-section">
        <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> 

<!-- End: introduction -->


<!-- What is HTML -->

      <section id="What_is_HTML" class="main-section">
        <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:
            </p>
            <code class="code">my cat is very grumpy</code>
            <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 class="code">&lt;p&gt;my cat is very grumpy&lt;&frasl;p&gt;</code>
        </article>
      </section>   

<!-- End : What is HTML -->


<!-- Anatomy of HTML elements -->

      <section id="Anatomy_of_HTML_elements" class="main-section">
        <header>Anatomy of HTML elements</header>
        <article>
          <p>
            Let's explore this paragraph element a bit further.
          </p>
          <img src="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics/grumpy-cat-small.png" alt="An example of html code with paragraph elements">
          <p>
            The main parts of our element are as follows:
          </p>
            <ol class="anatomy-list">
              <li><strong>The opening tag:</strong> This consists of the name of the element (in this case, p), wrapped in opening and closing angle brackets. This states where the element begins or starts to take effect — in this case where the paragraph begins.</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 states where the element ends — in this case where the paragraph ends. Failing to add a closing tag is one of the standard beginner errors and can lead to strange results.</li>
              <li><strong>The content:</strong> This is the content of the element, which in this case, is just text.</li>
              <li><strong>The element:</strong> The opening tag, the closing tag, and the content together comprise the element.</li>
            </ol>
          
          <p>
            Elements can also have attributes that look like the following:
          </p>
            <img src="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics/grumpy-cat-attribute-small.png" alt="an example of html code showing the attribute section">
          <p>
            Attributes contain extra information about the element that you don't want to appear in the actual content. Here, class is the attribute name and editor-note is the attribute value. The class attribute allows you to give the element a non-unique identifier that can be used to target it (and any other elements with the same class value) with style information and other things.
          </p>
          <p>
            An attribute should always have the following:
          </p>
            <ol class="anatomy-list">
              <li>A space between it and the element name (or the previous attribute, if the element already has one or more attributes).</li>
              <li>The attribute name followed by an equal sign.</li>
              <li>The attribute value wrapped by opening and closing quotation marks.</li>
            </ol>
        </article>
      </section>

<!-- End: Anatomy of HTML elements -->


<!-- Nesting elements -->

      <section id="Nesting_elements" class="main-section">
        <header>Nesting Elements</header>
        <article>
          <p>
            You can put elements inside other elements too — this is called nesting. If we wanted to state that our cat is <strong>very</strong> grumpy, we could wrap the word "very" in a &lt;strong&gt; element, which means that the word is to be strongly emphasized:
          </p>
            <code class="code">&lt;p&gt;my cat is &lt;strong&gt;very&lt;&frasl;strong&gt; grumpy&lt;&frasl;p&gt;</code>
          <p>
            You do however need to make sure that your elements are properly nested. In the example above, we opened the &lt;p&gt; element first, then the &lt;strong&gt; element; therefore, we have to close the &lt;strong&gt; element first, then the &lt;p&gt; element. The following is incorrect:
          </p>
            <code class="incorrect-code">&lt;p&gt;my cat is &lt;strong&gt;very grumpy&lt;&frasl;p&gt;&lt;&frasl;strong&gt;</code>
          <p>
            The elements have to open and close correctly so that they are clearly inside or outside one another. If they overlap as shown above, then your web browser will try to make the best guess at what you were trying to say, which can lead to unexpected results. So don't do it!
          </p>
        </article>
      </section>

<!-- End: Nesting elements -->

<!-- Empty elements -->

      <section id="Empty_elements" class="main-section">
        <header>Empty elements</header>
        <article>
          <p>
            Some elements have no content and are called empty elements. Take the &lt;img&gt; element that we already have in our HTML page:
          </p>
            <code class="code">&lt;img src="images/firefox-icon.png" alt="My test image" &frasl;&gt;</code>
          <p>
            This contains two attributes, but there is no closing &lt;&frasl;img&gt; tag and no inner content. This is because an image element doesn't wrap content to affect it. Its purpose is to embed an image in the HTML page in the place it appears.
          </p>
        </article>
      </section>

<!-- End: Empty elements -->


<!-- Anatomy of HTML doc -->

      <section id="Anatomy_of_HTML_documents" class="main-section">
        <header>Anatomy of HTML Documents</header>
        <article>
          <p>
            That wraps up the basics of individual HTML elements, but they aren't handy on their own. Now we'll look at how individual elements are combined to form an entire HTML page. Let's revisit the code we put into our <em>index.html</em> example:
          </p>
            <pre><code>
&lt;!DOCTYPE html&gt;
&lt;html lang="en-US"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" &frasl;&gt;
    &lt;meta name="viewport" content="width=device-width" &frasl;&gt;
    &lt;title&gt;My test page&lt;&frasl;title&gt;
  &lt;&frasl;head&gt;
  &lt;body&gt;
    &lt;img src="images/firefox-icon.png" alt="My test image" &frasl;&gt;
  &lt;&frasl;body&gt;
&lt;&frasl;html&gt;
            </code></pre>
          <p>
            Here, we have the following:
          </p>
            <ul>
              <li><strong>&lt;!DOCTYPE html&gt;</strong> — doctype. It is a required preamble. In the mists of time, when HTML was young (around 1991/92), doctypes were meant to act as links to a set of rules that the HTML page had to follow to be considered good HTML, which could mean automatic error checking and other useful things. However these days, they don't do much and are basically just needed to make sure your document behaves correctly. That's all you need to know for now.</li>
              <li><strong>&lt;html&gt;&lt;&frasl;html&gt;</strong> — the &lt;html&gt; element. This element wraps all the content on the entire page and is sometimes known as the root element. It also includes the lang attribute, setting the primary language of the document.</li>
              <li><strong>&lt;head&gt;&lt;&frasl;head&gt;</strong> — the &lt;head&gt; element. This element acts as a container for all the stuff you want to include on the HTML page that isn't the content you are showing to your page's viewers. This includes things like keywords and a page description that you want to appear in search results, CSS to style our content, character set declarations, and more.</li>
              <li><strong>&lt;meta charset="utf-8" &frasl;&gt;</strong> — This element sets the character set your document should use to UTF-8 which includes most characters from the vast majority of written languages. Essentially, it can now handle any textual content you might put on it. There is no reason not to set this and it can help avoid some problems later on.</li>
              <li><strong>&lt;meta name="viewport" content="width=device-width" &frasl;&gt;</strong> — This viewport element ensures the page renders at the width of viewport, preventing mobile browsers from rendering pages wider than the viewport and then shrinking them down.</li>
              <li><strong>&lt;title&gt;My test page&lt;&frasl;title&gt;</strong> — the &lt;title&gt; element. This sets the title of your page, which is the title that appears in the browser tab the page is loaded in. It is also used to describe the page when you bookmark/favorite it.</li>
              <li><strong>&lt;body&gt;&lt;&frasl;body&gt;</strong> — the &lt;body&gt; element. This contains all the content that you want to show to web users when they visit your page, whether that's text, images, videos, games, playable audio tracks, or whatever else.</li>
            </ul>
        </article>
      </section>  

<!-- Anatomy of HTML doc -->

<!-- Images in HTML -->

      <section id="Images_in_HTML" class="main-section">
        <header>Images in HTML</header>
        <article>
          <p>
            Let's turn our attention to the &lt;img&gt; element again:
          </p>
            <code class="code">
              &lt;img src="images/firefox-icon.png" alt="My test image" &frasl;&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 the alt 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>
            <div class="broken-image">
            <img src="an_image_location" alt="My broken test image">
            </div>
          <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 would be text describing what image should have been there.
          </p>
        </article>
      </section>  

<!-- End: Images in HTML -->

<!-- Marking up text -->

      <section id="Marking_up_text" class="main-section">
        <header>Marking up text</header>
        <article>
          <header class="sub-head">Headings</header> 
            <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>
              <pre><code>
&lt;!-- 4 heading levels: --&gt;

&lt;h1&gt;My main title&lt;&frasl;h1&gt;

&lt;h2&gt;My top level heading&lt;&frasl;h2&gt;

&lt;h3&gt;My subheading&lt;&frasl;h3&gt;

&lt;h4&gt;My sub-subheading&lt;&frasl;h4&gt;
              </code></pre>
          <header class="sub-head">Paragraphs</header>
            <p>
              As explained above, &lt;p&gt; elements are for containing paragraphs of text; you'll use these frequently when marking up regular text content:
            </p>
              <code class="code">
                &lt;p&gt;This ia a single paragraph&lt;&frasl;p&gt;
              </code>
          <header class="sub-head">Lists</header>
            <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><strong>Unordered lists</strong> 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><strong>Ordered lists</strong> 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>
              <pre><code>
&lt;p&gt;
  At Mozilla, we're a global community of technologists, thinkers, and builders

  working together…
&lt;&frasl;p&gt;
              </code></pre>
            <p>
              We could modify the markup to this
            </p>
              <pre><code>
&lt;p&gt;At Mozilla, we're a global community of&lt;&frasl;p&gt;

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

&lt;p&gt;working together…&lt;&frasl;p&gt;
              </code></pre>
        </article>
      </section> 

<!-- End: Marking up text -->  

<!-- Links -->

      <section id="Links" class="main-section">
        <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</li>
              <li>Give the &lt;a&gt; element an href attribute</li>
              <li>Fill in the value of this attribute with the web address that you want the link to:</li>
            </ol>
            <code class="code">
              &lt;a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto&lt;&frasl;a&gt;
            </code>
          <p>
            You might get unexpected results if you omit the <strong>https://</strong> or <strong>http://</strong> 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>   

<!-- End: Links -->

<!-- Reference -->

<section id="Reference" class="main-section">
        <header>Reference</header>
        <article>
            <ul>
            <li>This information has been gathered from <a class="ref-link" target="blank" href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics">MDN Webdocs</a> and used to compile this HTML page as part of a <a class="ref-link" target="blank" href="https://www.freecodecamp.org">freeCodeCamp</a> project.</li>
            </ul>
          </article>
      </section> 

<!-- End: Reference -->
      </main>
    </body>
</html>
  

I suggest putting your code somewhere online like in codepen of jsfiddle so that people can try to follow your description of the visual issues in a visual way.

1 Like

Link to Code Pen:

so what is the desired result at a smaller width?
vs say a cell-phone width?

You need to figure out what you want to see at each ‘break-point’ in the screen size.
(like maybe you want the menu to turn into a hamburger type menu or maybe you want it to go sideways across the top of the screen? You have to figure this out then code for that)

1 Like

Well initially it wasn’t shrinking down at all when shrinking the screen size which I sorted out.

The size it gets down to now before stopping would make sense to switch to a mobile view.

I was thinking of doing the navbar across the top with either a simple scroll on the side or a drop down from a hamburger button with the options. I know it prob doesn’t make much sense for this use case to have a menu with drop down but interested to code it in and see how it’s done.

I will add a media query in for that break point.

Thanks for your time hbar1st

1 Like

It’s all good to pass but just out of curiosity there are a couple of things which still bug me and not sure what causes them or how you would go about fixing them.

I’ve set the media query to kick in and it changes the nav bar to the top with a burger menu and drop down for the sections, the two things that bug me are:

  1. It still only responsively shrinks to around 590px wide then it stays that size and a scroll bar comes in.

  2. When you use the drop down nav links they start up the page behind the navbar is there a way to set where the linked item will start from so that when the link is clicked it starts off below the navbar?

Codepen (updated):

1 Like

you’ve done a great job with it looks like.

I

Try playing with the margin-top values. For eg. you can make it so the margin-top of the specific section being linked to is just a hair bigger than the width of the menu-bar…

Not sure about question 1… I didn’t notice but at 590px we are talking about a cellphone almost size? (or maybe a portrait tablet size)… So you need to think about what that means for these users. (is the scroll bar a good or bad thing)

Edit: well I can see now the problem with the scrollbar. It is happening for 2 reasons that I can tell. The main one being that your pre/code blocks are too wide.

Thank you for taking a look.

Would this just be a case of setting another media query to shrink down the size of the pre & code blocks suitable for mobile or is there a way to make them responsive. There’s no set size on them anywhere but I guess the pre blocks being pre-formatted are something to do with it.

honestly I tried to do that but they wouldn’t shrink.
The other option I just read about it is to make the block itself scrollable without making the whole page scrollable horizontally.

Then it seems you can also use Bootstrap to do this (if you know how)

Have not used boot strap so not familiar with it.

I have updated a couple of bits and it is better but only one code box becomes scrollable, and it stops shrinking shortly after this not effecting the rest of the boxes and I’m not sure why.

It doesn’t make a huge difference it just odd why it would so this and curious as to what is stopping it form going further.

I’ve updated the code pen above.

Appreciate all the help and the original bits are solved so am happy for this thread to be marked off as solved and closed.

The other bits are just curiosities that I would be keen on figuring out.

Thanks again ! :grin:

I think the ones that are not scrolling are just wrapping (you seem to have adjusted the font size as well).
I didn’t notice a box that needed to scroll that was getting cut-off for eg.
They either wrapped down or they scrolled.

1 Like