freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-css-variables-by-buil.../5d822fd413a79914d39e98cc.md

109 lines
2.3 KiB
Markdown

---
id: 5d822fd413a79914d39e98cc
title: Step 4
challengeType: 0
dashedName: step-4
---
# --description--
Dentro `head`, annida un elemento `meta` con un `charset` di `UTF-8`, un elemento `title` con il titolo `City Skyline` e un elemento `link` che linka il tuo file `styles.css`.
# --hints--
Dovresti creare un elemento `meta` dentro l'elemento `head`.
```js
assert.exists(document.querySelector('head > meta'));
```
Dovresti assegnare al tag `meta` un attributo `charset` con il valore `UTF-8`.
```js
assert.equal(document.querySelector('head > meta')?.getAttribute('charset')?.toLowerCase(), 'utf-8');
```
Il codice dovrebbe avere un elemento `title`.
```js
const title = document.querySelector('title');
assert.exists(title);
```
L'elemento `title` dovrebbe essere all'interno dell'elemento `head`.
```js
assert.exists(document.querySelector('head > title'));
```
Il progetto dovrebbe avere il titolo `City Skyline`.
```js
const title = document.querySelector('title');
assert.equal(title.text.toLowerCase(), 'city skyline')
```
Fai attenzione all'uso delle maiuscole/minuscole e all'ortografia nel titolo.
```js
const title = document.querySelector('title');
assert.equal(title.text, 'City Skyline');
```
Il codice dovrebbe avere un elemento `link`.
```js
assert.match(code, /<link/)
```
Non dovresti cambiare i tag `head` esistenti. Assicurati di non aver eliminato il tag di chiusura.
```js
const heads = document.querySelectorAll('head');
assert.equal(heads?.length, 1);
```
Dovresti avere un elemento `link` auto-concludente.
```js
assert(document.querySelectorAll('link').length === 1);
```
L'elemento `link` dovrebbe trovarsi all'interno dell'elemento `head`.
```js
assert.exists(document.querySelector('head > link'));
```
L'elemento `link` dovrebbe avere un attributo `rel` con il valore `stylesheet`.
```js
const link_element = document.querySelector('link');
const rel = link_element.getAttribute("rel");
assert.equal(rel, "stylesheet");
```
L'elemento `link` dovrebbe avere un attributo `href` con il valore `styles.css`.
```js
const link = document.querySelector('link');
assert.equal(link.dataset.href, "styles.css");
```
# --seed--
## --seed-contents--
```html
<!DOCTYPE html>
<html lang="en">
--fcc-editable-region--
<head>
</head>
--fcc-editable-region--
<body>
</body>
</html>
```