Technical Documentation Page - Build a Technical Documentation Page

Problems with ids

I can’t send the code since I didn’t pass point 4

The point says like this:

  1. Each section element with the class of main-section should also have an id that corresponds with the text of each header contained within it. Any spaces should be replaced with underscores (e.g. The section that contains the header “JavaScript and Java” should have a corresponding id="JavaScript_and_Java")

I have already tried to rewrite the code many times and also try in another browser and it still doesn’t work. Any idea what the error is?

<!DOCTYPE html> 
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
    <title>Technical Documentation Page</title>
  </head>
  <body>
    <nav id="navbar"> 
      <header>JS Documentation</header>
      <li><a class="nav-link" href="#Introduction">Introduction</a></li>
      <li><a class="nav-link" href="#What-you-should-already-know">What you should already know</a>
</li>
      <li><a class="nav-link" href="#Hello-World">Hello World</a></li>
      <li><a class="nav-link" href="#Variables">Variables</a></li>
      <li><a class="nav-link" href="#Constants">Constants</a></li>
    </nav>
    <main id="main-doc">
      <section class="main-section" id="Introduction"> 
        <header>Introduction</header>
        <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> 
          <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>Server-side JavaScript extends the core language by supplying objects relevant to running JavaScript on a server. For example, server-side extensions allow an application to communicate with a database, provide 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="What-you-should-already-know"> 
        <header>What you should already know</header>
        <p>This guide assumes you have the following basic background:</p>
        <ul> 
          <li>A general understanding of the Internet and the World Wide Web (WWW).</li>
          <li>Good working knowledge of HyperText Markup Language (HTML).</li>
          <li>Some programming experience. If you are new to programming, try one of the tutorials linked on the main page about JavaScript.</li>
        </ul>
      </section>
      
      <section class="main-section" id="Hello-world"> 
        <header>Hello world</header>
        <p>To get started with writing JavaScript, open the Scratchpad and write your first "Hello world" JavaScript code:</p>
        <code>function greetMe(yourName) { alert("Hello " + yourName); }
greetMe("World");</code>
        <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="Variables"> 
        <header>Variables</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> 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).</p>
        <h2>Declaring variables</h2>
        <p>You can declare a variable in three ways:</p>
        <p>With the keyword var. For example,</p>
        <code>var x = 42.</code>
        <p>This syntax can be used to declare both local and global variables.</p>
        <p>By simply assigning it a value. For example,</p>
        <code>x = 42.</code>
        <p>This always declares a global variable. It generates a strict JavaScript warning. You shouldn't use this variant.</p>
        <p>With the keyword let. For example,</p>
        <code>let y = 13.</code>
      </section>
      <section class="main-section" id="Constants"> 
        <header>Constants</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>
        <code> const PI = 3.14;</code>
        <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>
        <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> However, object attributes are not protected, so the following statement is executed without problems.</p>
        <code> const MY_OBJECT = {"key": "value"}; MY_OBJECT.key =
"otherValue";</code>
      </section>
    </main>
  </body>
</html>

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 and welcome to the community :smiley:!
Congratulations on coming so far :tada:!
Try separating the words in your id with a underscore instead of an dash:

#What_you_should-already-know

Should be:

#What_you_should_already_know

Make sure to switch both the id and the href value.
Do this for all your multi-word ids.
Hope this helps!

1 Like

That was the solution, thank you very much! I would never have imagined it!

1 Like

That’s What the forum is made for :smile:!
I’m glad you sorted it out.
Happy Coding and have a great night/day!

2 Likes

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