freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-accessibility-by-buil.../614202874ca576084fca625f.md

4.3 KiB

id title challengeType dashedName
614202874ca576084fca625f Step 16 0 step-16

--description--

Ogni attributo role con valore region richiede un'etichetta visibile, che dovrebbe essere referenziata dall'attributo aria-labelledby.

Dai agli elementi section i seguenti attributi aria-labelledby:

  • student-info
  • html-questions
  • css-questions

Poi, all'interno di ogni elemento section annida un elemento h2 con un id che corrisponde all'attributo aria-labelledby. Assegna a ogni elemento h2 un testo adatto.

--hints--

Dovresti dare al primo elemento section un attributo aria-labelledby con il valore student-info.

assert.equal(document.querySelectorAll('section')?.[0]?.getAttribute('aria-labelledby'), 'student-info');

Dovresti dare al secondo elemento section un attributo aria-labelledby con il valore html-questions.

assert.equal(document.querySelectorAll('section')?.[1]?.getAttribute('aria-labelledby'), 'html-questions');

Dovresti dare al terzo elemento section un attributo aria-labelledby con il valore css-questions.

assert.equal(document.querySelectorAll('section')?.[2]?.getAttribute('aria-labelledby'), 'css-questions');

Dovresti annidare un elemento h2 all'interno del primo elemento section.

assert.equal(document.querySelectorAll('section')?.[0]?.querySelectorAll('h2')?.length, 1);

Dovresti annidare un elemento h2 all'interno del secondo elemento section.

assert.equal(document.querySelectorAll('section')?.[1]?.querySelectorAll('h2')?.length, 1);

Dovresti annidare un elemento h2 all'interno del terzo elemento section.

assert.equal(document.querySelectorAll('section')?.[2]?.querySelectorAll('h2')?.length, 1);

Dovresti assegnare al primo elemento h2 un attributo id con il valore student-info.

assert.equal(document.querySelectorAll('h2')?.[0]?.id, 'student-info');

Dovresti assegnare al secondo elemento h2 un attributo id con il valore html-questions.

assert.equal(document.querySelectorAll('h2')?.[1]?.id, 'html-questions');

Dovresti assegnare al terzo elemento h2 un attributo id con il valore css-questions.

assert.equal(document.querySelectorAll('h2')?.[2]?.id, 'css-questions');

Dovresti assegnare al primo elemento h2 un testo adatto. Suggerimento: io avrei scelto Student Info

assert.isAtLeast(document.querySelectorAll('h2')?.[0]?.textContent?.length, 1);

Dovresti assegnare al secondo elemento h2 un testo adatto. Suggerimento: io avrei scelto HTML

assert.isAtLeast(document.querySelectorAll('h2')?.[1]?.textContent?.length, 1);

Dovresti assegnare al terzo elemento h2 un testo adatto. Suggerimento: io avrei scelto CSS

assert.isAtLeast(document.querySelectorAll('h2')?.[2]?.textContent?.length, 1);

--seed--

--seed-contents--

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="freeCodeCamp Accessibility Quiz practice project" />
    <title>Accessibility Quiz</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <header>
      <img id="logo" src="https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg">
      <h1>HTML/CSS Quiz</h1>
      <nav>
        <ul>
          <li><a>INFO</a></li>
          <li><a>HTML</a></li>
          <li><a>CSS</a></li>
              </ul>
      </nav>
    </header>
    <main>
--fcc-editable-region--
      <form method="post" action="https://freecodecamp.org/practice-project/accessibility-quiz">
        <section role="region"></section>
        <section role="region"></section>
        <section role="region"></section>
      </form>
--fcc-editable-region--
    </main>
  </body>
</html>

body {
  background: #f5f6f7;
    color: #1b1b32;
    font-family: Helvetica;
    margin: 0;
}

header {
  width: 100%;
    height: 50px;
    background-color: #1b1b32;
    display: flex;
}

#logo {
  width: max(100px, 18vw);
    background-color: #0a0a23;
  aspect-ratio: 35 / 4;
    padding: 0.4rem;
}

h1 {
  color: #f1be32;
    font-size: min(5vw, 1.2em);
}

nav {
    width: 50%;
    max-width: 300px;
    height: 50px;
}

nav > ul {
    display: flex;
    justify-content: space-evenly;
}