Technical Documentation Page - Build a Technical Documentation Page

I need help with the navigation bar.

<!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">
  </head>
  <body>
    <nav id="navbar">
      <header class="nav-head">JS Documentation</header>
      <ul class="navigation">
        <li><a id="one" class="nav-link" href="#Introduction">Introduction</a></li>
        <li><a class="nav-link" href="#Hello_World">Hello World</a></li>
        <li><a class="nav-link" href="#Function_declarations">Function declarations</a></li>
        <li><a class="nav-link" href="#Variables">Variables</a></li>
        <li><a class="nav-link" href="#Constants">Constants</a></li>
     </ul>
    </nav>
   <main id="main-doc">
     
    <section class="main-section" id="Introduction">
      <header><h1>Introduction</h1></header>
      <code></code>
      <p>JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment (for example, a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.</p>
      <p>JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects; for example:</p>
      <ul class="list">
        <li>Client-side JavaScript extends the core language by supplying objects to control a browser and its Document Object Model (DOM). For example, client-side extensions allow an application to place elements on an HTML form and respond to user events such as mouse clicks, form input, and page navigation.</li>
        <li>continuity of information from one invocation to another of the application, or perform file manipulations on a server.</li>
      </ul>
    </section>
    <section class="main-section" id="Hello_World">
      <header><h1>Hello World<h1></header>
      <p>To get started with writing JavaScript, open the Scratchpad and write your first "Hello world" JavaScript code:</p>
      <p class="example"><code>function greetMe(yourName) { alert("Hello " + yourName); }
greetMe("World");</code></p>
      <p>Select the code in the pad and hit Ctrl+R to watch it unfold in your browser!
</p>
    </section>
    <section class="main-section" id="Function_declarations">
      <header><h1>Function declarations</h1></header>
      <p>A function definition (also called a function declaration, or function statement) consists of the function keyword, followed by:</p>
      <ul class="list">
        <li>The name of the function.</li>
        <li>A list of arguments to the function, enclosed in parentheses and separated by commas.</li>
        <li>The JavaScript statements that define the function, enclosed in curly brackets, { }.</li>
      </ul>
      <p>For example, the following code defines a simple function named square:</p>
      <p class="example"><code>function square(number) { return number * number; }</code></p>
      <p>The function square takes one argument, called number. The function consists of one statement that says to return the argument of the function (that is, number) multiplied by itself. The return statement specifies the value returned by the function.</p>
      <p class="example"><code>return number * number;</p>
      <p>Primitive parameters (such as a number) are passed to functions by value; the value is passed to the function, but if the function changes the value of the parameter, this change is not reflected globally or in the calling function.</code></p>

    </section>
    <section class="main-section" id="Variables">
      <header><h1>Variables</h1></header>
      <p>You use variables as symbolic names for values in your application. The names of variables, called identifiers, conform to certain rules.</p>
      <p class="example"><code>A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).</code></p>
      <p>You can use ISO 8859-1 or Unicode letters such as ĂĄ and ĂĽ in identifiers. You can also use the Unicode escape sequences as characters in identifiers. Some examples of legal names are Number_hits, temp99, and _name.</p>
    </section>
    <section class="main-section" id="Constants">
      <header><h1>Constants</h1></header>
      <p>You can create a read-only, named constant with the const keyword. The syntax of a constant identifier is the same as for a variable identifier: it must start with a letter, underscore or dollar sign and can contain alphabetic, numeric, or underscore characters.</p>
      <p class="example"><code>const PI = 3.14;</code></p>
      <p>A constant cannot change value through assignment or be re-declared while the script is running. It has to be initialized to a value.</p>
      <p>The scope rules for constants are the same as those for let block scope variables. If the const keyword is omitted, the identifier is assumed to represent a variable.</p>
      <p>You cannot declare a constant with the same name as a function or variable in the same scope. For example:</p>
      <p class="example"><code>// THIS WILL CAUSE AN ERROR function f() {}; const f = 5; // THIS
WILL CAUSE AN ERROR ALSO function f() { const g = 5; var g;
//statements }</code></p>
      <p>However, object attributes are not protected, so the following statement is executed without problems.</p>
      <p class="example"><code>const MY_OBJECT = {"key": "value"}; MY_OBJECT.key =
"otherValue";</code></p>
    </section>
  </main>
  </body>
</html>
*:not(h1){
  font-size:19px;
}

.example{
  background-color:#d3d3d3;
  padding:20px;
  margin-left:20px;
}
.list{
  padding: 8px 75px;
}
#navbar{
  position:fixed;
  float:left;
  width:250px;
  height:100%;
  margin-left:0px;
}
.nav-head{
  font-size:20px;
  font-style:bold;
}
.nav-link{
  text-decoration:none;
  list-style-type:none;
  color:black;
  border:1px solid black;
  padding-left:0;
}
#main-doc{
  margin-left:200px;
}
.navigation{
  list-style-type:none;

Here’s how it should look like:


Here’s how mine looks like:

Your browser information:

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

Challenge Information:

Technical Documentation Page - Build a Technical Documentation Page

Hello @GhadyKeyrouz !

Try changing it from fixed to flex if you want it to be on the left.

In case you need help with media query, I am adding a link with great examples and explanations that I found in the fCC News category.

FCC News Media Query

I hope this helps you move on in your coding journey.

I know how to add the media query, I just haven’t added it yet. I tried making the position flex but then when I scroll down the navigation bar disappears, when using position fixed it stays to the left while scrolling I just don’t know how to make it look like the other picture.

1 Like

I fixed my code a little but, it’s closer to what I want it to be but still not there yet.(The # you see at the bottom are for the list so I could move the borders . How should I continue?

@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}
*:not(h1){
  font-size:19px;
}

.example{
  background-color:#d3d3d3;
  padding:20px;
  margin-left:20px;
}
.list{
  padding: 8px 75px;
}
#navbar{
  position:fixed;
  float:left;
  width:256px;
  height:100%;
  margin-left:0px;

}
.nav-head{
  font-size:20px;
  font-style:bold;
  border-right:1px solid black;
  border-bottom:1px solid black;
}
.nav-link{
  list-style-type:none;
  text-decoration:none;
  color:black;
  border-right:1px solid black;
  border-bottom:1px solid black;

  padding-left:0;
}
#main-doc{
  margin-left:200px;
}
.navigation{
  list-style-type:none;
  padding-left:0px;
}
#intro{
  padding:0 45; 
}
#hello{
  padding:0 45; 
}
#func{
  padding:0 10; 
}
#var{
  padding:0 56.5; 
}
#cons{
padding:0 54.5; 
}
1 Like

Making the .nav-link elements block-level elements (display: block) and giving them some padding would kind of get you there.

2 Likes

Sorry! I misunderstood the question. My mistake.

I see @lasjorg has provided some gudiance. This guidance is usually reliable and on the spot from what I have observed.

Keep up your great progress.

1 Like

Okay thank you so much I’m a lot closer now to the end. Now I’ve got 2 things left: first the navigation bar borders doesn’t touch the edge of the screen there’s like 5 pixels left on top and to the left, second the list inside the navigation bar isn’t aligned to the left they’re almost at the middle even though I have a align-items: left; I want all the links to be aligned straight to the left and the header can be in the middle which it already is.

@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}
*:not(h1){
  font-size:19px;
}

.example{
  background-color:#d3d3d3;
  padding:20px;
  margin-left:20px;
}
.list{
  padding: 8px 75px;
}
#navbar{
  border-right:1px solid black;
  position:fixed;
  float:left;
  width:220px;
  height:100%;
  margin-left:0px;

}
.nav-head{
  text-align:center;
  margin-top:10;
  font-size:25px;
  font-weight:bold;
  border-bottom:1px solid black;
}
.nav-link{
  display:block;
  text-align:left;
  margin:0 0 20;
  list-style-type:none;
  text-decoration:none;
  color:black;
  border-bottom:1px solid black;

  padding-left:0;
}
#main-doc{
  margin-left:240px;
}
.navigation{
  list-style-type:none;
  padding-left:0px;
}
#intro{
  padding:0 45; 
}
#hello{
  padding:0 45; 
}
#func{
  padding:0 10;
}
#var{
  padding:0 56.5; 
}
#cons{
padding:0 54.5; 
}

Here’s a picture of what it looks like:

1 Like

Use the browser dev tools to inspect the styles.

You have a default value on body that is causing the gap, see if you can figure out what CSS property it is you need to change (zero out).

I don’t see the link being centered when I test your code (HTML from the first post and CSS from the last post). But again you can inspect the styles.

1 Like

I opened the browser dev tools and there were too many things I gave up, I just finished the program without the navigation being perfect (since they don’t check your css code). But I think I did fine with this project, came very close to perfection. Thank you for your time effort, much appreciated.

I know it can be a lot but the dev tools for inspecting and changing styles are super important to learn.


If you look at the body element you will see it has a default margin. Set that to 0 in your styles.

As for the text alignment I see nothing in the CSS you posted that would cause that. They are clearly center-aligned. So I would check the styles for the ul/li and if it isn’t set directly on the elements they may be inheriting the alignment from a parent element (all the way up to the body/html).

Alright I searched in the dev tools and found the body element, it already had a margin of 0 and I tried changing it around not much happened. As for the alignment I have a text-align: left; in the nav-list class but the “function declaration” is to the left and the rest are in the middle of “function declaration”

I was working on another project and I they told me to put a margin and padding to 0 in the *{
} I tried it on this project and the borders are fixed, there are no more gaps but the whole project’s padding and margin are now different. How can I fix it?

The * selector selects all elements. There is no fix other than adding back all the margin and padding to each element you want it on.


There is no reason why the * selector would remove the margin from the body but the body selector wouldn’t. That doesn’t make any sense. Not only is the body selector targeting the body element it also has higher specificity than the * selector.

For example, this will apply margin to the body even though it is removed later in the cascade using *.

body {
  margin: 80px;
}

* {
  margin: 0;
}

Alright I changed it to remove the margin from the body not the all selector and for some reason it worked, the navigation’s border is now fixed but the whole project’s padding is normal.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.