Back to Freecodecamp

Step 5

curriculum/challenges/english/blocks/learn-html-forms-by-building-a-registration-form/62cc5b1779e4d313466f73c5.md

latest1.7 KB
Original Source

--description--

Nest a link element within the head element. Give it a rel attribute with a value of stylesheet and an href attribute with a value of styles.css.

--hints--

Your code should have a link element.

js
assert.isNotNull(document.querySelector('link'));

You should not change your existing head tags. Make sure you did not delete the closing tag.

js
const heads = document.querySelectorAll('head');
assert.strictEqual(heads?.length, 1);

You should have one link element.

js
assert.strictEqual(document.querySelectorAll('link')?.length, 1);

Your link element should be a void element, it should not have an end tag </link>.

js
assert.notMatch(code, /<\/link>/);

Your link element should be inside your head element.

js
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
const headElementContent = code.match(headContentRegex);

const headElement = document.createElement("head");
headElement.innerHTML = headElementContent;
assert.isNotNull(headElement.querySelector('link'));

Your link element should have a rel attribute with the value stylesheet.

js
const linkElement = document.querySelector('link');
const rel = linkElement?.getAttribute("rel");
assert.strictEqual(rel, "stylesheet");

Your link element should have an href attribute with the value styles.css.

js
const link = document.querySelector('link');
assert.strictEqual(link?.dataset.href, "styles.css");

--seed--

--seed-contents--

html
<!DOCTYPE html>
<html lang="en">
--fcc-editable-region--
  <head>
    <meta charset="UTF-8">
    <title>Registration Form</title>
  </head>
--fcc-editable-region--
  <body>
  </body>
</html>