Can anyone help me with this I have tried matching the .main-section id with the first child element I have double checked but still getting error

Can anyone help me with this I have tried matching the .main-section id with the first child element I have double checked but still getting error

““Each .main-section should have an id that matches the text of its first child, having any spaces in the child’s text replaced with underscores (_ ) for the id’s.””

here is my code:

<main id="main-doc">
      <section id="Introduction" class="main-section">
            <header><h2>Introduction</h2></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><p>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.</p></li>
        <li><p>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.</p></li>
        </ul>
          
      </section>
       <section id="What_you_should_already_know" class="main-section">
        <header><h2>What you should already know</h2></header>
          <p>This guide assumes you have the following basic background:</p>
          <ul>
            <li><p>A general understanding of the Internet and the World Wide Web (WWW).</p></li>
            <li><p>Good working knowledge of HyperText Markup Language (HTML).</p></li>
            <li><p>Some programming experience. If you are new to programming, try one of the tutorials linked on the main page about JavaScript.</p>
</li>
          </ul>

      </section>
     
      <section id="JavaScript_and_Java" class="main-section">
        <header><h2>JavaScript and Java</h2></header>
        <p>JavaScript and Java are similar in some ways but fundamentally different in some others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.</p>
        <p>In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.

</p>
<p>JavaScript is a very free-form language compared to Java. You do not have to declare all variables, classes, and methods. You do not have to be concerned with whether methods are public, private, or protected, and you do not have to implement interfaces. Variables, parameters, and function return types are not explicitly typed.</p>
 
      </section>
      <section id="Declaring_variables" class="main-section">
        <header><h2>Declaring variables</h2></header>
      <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>

      <p>The HTML element is used to define keyboard input. The content inside is displayed in the browser's default monospace font.</p>
      <code>The HTML element is used to define sample output from a computer program. The content inside is displayed in the browser's default monospace font.</code>
      </section>
      <section id="Variables" class="main-section">
        <header><h2>Variables</h2></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>
        <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 id="Constants" class="main-section">
        <header><h2>Constants</h2></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>

I’ve edited your code for readability. 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 (').

I just tested the HTML you pasted above and this test is passing for me.

The first test that isn’t passing is “You should have a nav element with an id of navbar.”

I got a pass for “You should have a nav element with an id of navbar .”

but no pass for “Each .main-section should have an id that matches the text of its first child, having any spaces in the child’s text replaced with underscores (_ ) for the id’s.”

I have tried using different words for the id and text but still won.t pass

Ahh, looking at the pic of the code you just posted, your opening main tag is on line 22 and I’m assuming there is more HTML above it. But the code you pasted above in this thread begins with the opening main tag, so I don’t think you gave us all of your code.

Please use the method described above by @JeremyLT to post all of your HTML in here so we can test it properly.

here is the html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Technical Documentation</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./styles.css">
  </head>
  <body>
    <nav id="navbar">
      <header><h1>JS Documentation</h1></header>
      <a class="nav-link" href="#Introduction">Introduction</a>
      <a class="nav-link" href="#What_you_should_already_know">What you should already know</a>
      <a class="nav-link" href="#JavaScript_and_Java">JavaScript and Java</a>
      <a class="nav-link" href="#Declaring_variables">Declaring variables</a>

      <a class="nav-link" href="#Variables">Variables</a>

      <a class="nav-link" href="#Constants">Constants</a>
    </nav>

    <main id="main-doc">
      <section class="main-section" id="Introduction">
            <header><h2>Introduction</h2></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><p>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.</p></li>
        <li><p>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.</p></li>
        </ul>
          
      </section>
       <section class="main-section" id="What_you_should_already_know">
        <header><h2>What you should already know</h2></header>
          <p>This guide assumes you have the following basic background:</p>
          <ul>
            <li><p>A general understanding of the Internet and the World Wide Web (WWW).</p></li>
            <li><p>Good working knowledge of HyperText Markup Language (HTML).</p></li>
            <li><p>Some programming experience. If you are new to programming, try one of the tutorials linked on the main page about JavaScript.</p>
</li>
          </ul>

      </section>
     
      <section class="main-section" id="JavaScript_and_Java">
        <header><h2>JavaScript and Java</h2></header>
        <p>JavaScript and Java are similar in some ways but fundamentally different in some others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.</p>
        <p>In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.

</p>
<p>JavaScript is a very free-form language compared to Java. You do not have to declare all variables, classes, and methods. You do not have to be concerned with whether methods are public, private, or protected, and you do not have to implement interfaces. Variables, parameters, and function return types are not explicitly typed.</p>
 
      </section>
      <section class="main-section" id="Declaring_variables">
        <header><h2>Declaring variables</h2></header>
      <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>

      <p>The HTML element is used to define keyboard input. The content inside is displayed in the browser's default monospace font.</p>
      <code>The HTML element is used to define sample output from a computer program. The content inside is displayed in the browser's default monospace font.</code>
      </section>
      <section class="main-section" id="Variables">
        <header><h2>Variables</h2></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>
        <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><h2>Constants</h2></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>here

The most recent HTML you pasted above is passing all of the HTML tests for me. You just need to add a media query.

I already added a media query and all the html passed all the test except for this

““Each .main-section should have an id that matches the text of its first child, having any spaces in the child’s text replaced with underscores (_ ) for the id’s.””


Hmm, I don’t know what to say. I just tested your HTML again and all the tests passed. Maybe someone else can test it and replicate your error? The only thing I can think of is that the HTML you are testing is not exactly the same as the HTML you pasted in here.

I copied and paste directly here

all the test passed now that I tried testing from google chrome browser

, I was using safari before.
Thank you

Interesting. I don’t have access to Safari at the moment so I can’t troubleshoot it myself. There could be an issue specific to Safari with how that particular test is implemented. I wouldn’t rule out the possibility that it worked in Safari at one time and then a recent update to Safari caused the test to stop working. The only way to really know is to have other Safari users test your HTML and see if they get the same result.

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