Learning to Code: Day 34 — Building a Technical Documentation Page
Hello ya’ll. Got me music on in the background and buzzing with this challenge from FreeCodeCamp, it’s a big one. Here’s the example structure to follow. Let’s look at those conditions we have to cover.
—
#1: I can see a
main
element with a correspondingid="main-doc"
, which contains the page's main content (technical documentation).#2: Within the
#main-doc
element, I can see severalsection
elements, each with a class ofmain-section
. There should be a minimum of 5.#3: The first element within each
.main-section
should be aheader
element which contains text that describes the topic of that section.#4: Each
section
element with the class ofmain-section
should also have an id that corresponds with the text of eachheader
contained within it. Any spaces should be replaced with underscores (e.g. Thesection
that contains the header "JavaScript and Java" should have a correspondingid="JavaScript_and_Java"
).#5: The
.main-section
elements should contain at least 10p
elements total (not each).#6: The
.main-section
elements should contain at least 5code
elements total (not each).#7: The
.main-section
elements should contain at least 5li
items total (not each).#8: I can see a
nav
element with a correspondingid="navbar"
.#9: The navbar element should contain one
header
element which contains text that describes the topic of the technical documentation.#10: Additionally, the navbar should contain link (
a
) elements with the class ofnav-link
. There should be one for every element with the classmain-section
.#11: The
header
element in the navbar must come before any link (a
) elements in the navbar.#12: Each element with the class of
nav-link
should contain text that corresponds to theheader
text within eachsection
(e.g. if you have a "Hello world" section/header, your navbar should have an element which contains the text "Hello world").#13: When I click on a navbar element, the page should navigate to the corresponding section of the
main-doc
element (e.g. If I click on anav-link
element that contains the text "Hello world", the page navigates to asection
element that has that id and contains the correspondingheader
.#14: On regular sized devices (laptops, desktops), the element with
id="navbar"
should be shown on the left side of the screen and should always be visible to the user.#15: My Technical Documentation page should use at least one media query.
First, as always, I jot out the document type and the meta data and sketch out the borders of the page which covers the conditions 1–13:
<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8">
<meta name=”website” content=”Technical Documentation Page”>
<title>Technical Documentation Page</title>
<style></style>
</head>
<body class=“body”>
<nav id=”navbar”>
<header>JS Documentation</header>
<a class=”nav-link” href=”#introduction”>Introduction</a>
<a class=”nav-link” href=”#what_we_know”>What We Know</a>
<a class=”nav-link” href=”#javascript_and_java”>JavaScript and Java</a>
<a class=”nav-link” href=”#hello_world”>Hello World</a>
<a class=”nav-link” href=”#the_variables”>The Variables</a>
</nav>
<main id=”main-doc”>
<section class=”main-section” id=”introduction”>
<header>Introduction</header>
<p><code></code></p>
<p><code></code></p>
</section>
<section class=”main-section” id=”what_we_know”>
<header>What We Know</header>
<p></p>
<p><code></code></p></section>
<section class=”main-section” id=”javascript_and_java”>
<header>JavaScript and Java</header>
<p></p>
<p><code></code></p>
</section>
<section class=”main-section” id=”hello_world”>
<header>Hello World</header>
<p><code></code></p>
<p></p>
<ol>
<li></li>
<li></li>
</ol>
</section>
<section class=”main-section” id=”the_variables”>
<header>The Variables</header>
<p></p>
<p></p>
<ol>
<li></li>
<li></li>
<li></li>
</ol>
</section></main>
</body>
</html>
Of course the layout of this is gonna look shit. But it’s a skinny horse that we now gotta beef out thanks to the data we input into the style tags. We need a media query to occur at least once, and to make the nav appear on the left for viewports such as laptops and desktops. The nav is also supposed to remain always visible to the user, that can easily be done by applying a position:fixed; to the nav element.
For all the p text I just pasted in some Ipsum text, the kinda bollocks you see in IKEA books in store. Fake like everything else there.
Handy little code: I found when I created the nav each option was underlined blue highlighted text for the navigation anchors, so I used a text-decoration: none; to remove that.
Note: It’s worth noting that when the mouse hovers over anchor text we can create the little Micky Mouse glove pointer cursor with a simple cursor:pointer; in the a declaration.
When I was writing the boundaries for the code elements, they where breaking out of their parent elements, so I fixed that with overflow-x: auto;.
..Several hours later..
And we’re finished! I added a background colour to the article elements only to see if they’d looked separated better, and the nav looks skinny on the left, but I’m sure as more sections were added it would fill out the left side. Check out my finished product.
See ya next time!