freeCodeCamp/curriculum/challenges/german/14-responsive-web-design-22/learn-responsive-web-design.../612e77aba7ca691f598feb02.md

1.4 KiB

id title challengeType dashedName
612e77aba7ca691f598feb02 Schritt 2 0 step-2

--description--

Add two meta tags, one to optimize your page for mobile devices, and one to specify an accepted charset for the page.

--hints--

You should add two meta elements to your page.

const meta = document.querySelector('meta');
assert.exists(meta);

You should have two meta elements.

const meta = document.querySelectorAll('meta');
assert(meta?.length === 2);

One meta element should have a name set to viewport, and content set to width=device-width, initial-scale=1.0.

const meta = [...document.querySelectorAll('meta')];
const target = meta?.find(m => m?.getAttribute('name') === 'viewport' && m?.getAttribute('content') === 'width=device-width, initial-scale=1.0' && !m?.getAttribute('charset'));
assert.exists(target);

The other meta element should have the charset attribute set to UTF-8.

const meta = [...document.querySelectorAll('meta')];
const target = meta?.find(m => !m?.getAttribute('name') && !m?.getAttribute('content') && m?.getAttribute('charset')?.toLowerCase() === 'utf-8');
assert.exists(target);

--seed--

--seed-contents--

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Piano</title>
    --fcc-editable-region--

    --fcc-editable-region--
  </head>
  <body></body>
</html>