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.
-
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.
-
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"><p>my cat is very grumpy<⁄p></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 <strong> element, which means that the word is to be strongly emphasized:
</p>
<p>
<code class="code"><p>my cat is <strong>very<⁄strong> grumpy<⁄p></code>
</p>
<p>
You do however need to make sure that your elements are properly nested. In the example above, we opened the <p> element first, then the <strong> element; therefore, we have to close the <strong> element first, then the <p> element. The following is incorrect:
</p>
<p>
<code class="incorrect_code"><p>my cat is <strong>very grumpy<⁄p><⁄strong></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 <img> element that we already have in our HTML page:
</p>
<p>
<code class="code"><img src="images/firefox-icon.png" alt="My test image" ⁄></code>
</p>
<p>
This contains two attributes, but there is no closing <⁄img> 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>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" ⁄>
<meta name="viewport" content="width=device-width" ⁄>
<title>My test page<⁄title>
<⁄head>
<body>
<img src="images/firefox-icon.png" alt="My test image" frasl;>
<⁄body>
<⁄html>
</code></pre>
</p>
<p>
Here, we have the following:
<ul>
<li><strong><!DOCTYPE html></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><html><⁄html></strong> â the <html> 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><head><⁄head></strong> â the <head> 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><meta charset="utf-8" ⁄></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><meta name="viewport" content="width=device-width" ⁄></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><title>My test page<⁄title></strong> â the <title> 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><body><⁄body></strong> â the <body> 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 <img> element again:
</p>
<p>
<code>
<img src="images/firefox-icon.png" alt="My test image" ⁄>
</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, <h1> - <h6>, although you'll commonly only use 3 to 4 at most:
</p>
<p>
<pre><code>
<!-- 4 heading levels: -->
<h1>My main title<⁄h1>
<h2>My top level heading<⁄h2>
<h3>My subheading<⁄h3>
<h4>My sub-subheading<⁄h4>
</pre></code>
</p>
<header class="sub-head">Paragraphs</header>
<p>
As explained above, <p> elements are for containing paragraphs of text; you'll use these frequently when marking up regular text content:
</p>
<p>
<code class="code">
<p>This ia a single paragraph<⁄p>
</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 <ul> 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 <ol> element.</li>
</ol>
</p>
<p>
Each item inside the lists is put inside an <li> (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>
<p>
At Mozilla, we're a global community of technologists, thinkers, and builders
working togetherâŚ
<⁄p>
</code></pre>
</p>
<p>
We could modify the markup to this
</p>
<p>
<pre><code>
<p>At Mozilla, we're a global community of<⁄p>
<ul>
<li>technologists<⁄li>
<li>thinkers<⁄li>
<li>builders<⁄li>
<⁄ul>
<p>working togetherâŚ<⁄p>
</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 â <a> â "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 <a> element</li>
<li>Give the <a> 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">
<a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto<⁄a>
</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: