2.9 KiB
id | title | challengeType | dashedName |
---|---|---|---|
61fd5a93fd62bb35968adeab | Step 1 | 0 | step-1 |
--description--
Imposta il tuo HTML con gli elementi DOCTYPE
, html
, head
e body
. Dai all'elemento head
gli appropriati elementi meta
per charset
e viewport
, un elemento title
con un titolo appropriato e un elemento link
per il foglio di stile.
--hints--
Il codice dovrebbe avere una dichiarazione <!DOCTYPE html>
.
assert(code.match(/<!DOCTYPE html>/i));
Il codice dovrebbe avere un elemento html
.
assert.equal(document.querySelectorAll('html')?.length, 1);
Il codice dovrebbe avere un elemento head
all'interno dell'elemento html
.
assert.equal(document.querySelectorAll('head')?.length, 1);
Il codice dovrebbe avere un elemento body
all'interno dell'elemento html
.
assert.equal(document.querySelectorAll('body')?.length, 1);
L'elemento head
dovrebbe trovarsi prima dell'elemento body
.
assert.equal(document.querySelector('body')?.previousElementSibling?.tagName, 'HEAD');
Dovresti avere due elementi meta
.
const meta = document.querySelectorAll('meta');
assert.equal(meta?.length, 2);
Un elemento meta
dovrebbe avere un name
impostato su viewport
e un content
impostato su 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);
L'altro elemento meta
dovrebbe avere l'attributo charset
impostato su 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);
Il codice dovrebbe avere un elemento title
.
const title = document.querySelector('title');
assert.exists(title);
L'elemento title
dovrebbe avere del testo.
const title = document.querySelector('title');
assert.isAtLeast(title?.textContent?.length, 1);
Il codice dovrebbe avere un elemento link
.
assert(/<link/.test(code))
L'elemento link
dovrebbe trovarsi all'interno dell'elemento head
.
assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/?>[\w\W\s]*<\/head>/i))
L'elemento link
dovrebbe avere un attributo rel
con il valore stylesheet
.
assert.match(code, /<link[\s\S]*?rel=('|"|`)stylesheet\1/)
L'elemento link
deve avere un attributo type
con il valore text/css
.
assert.match(code, /<link[\s\S]*?type=('|"|`)text\/css\1/)
L'elemento link
dovrebbe avere un attributo href
con il valore styles.css
.
assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
--seed--
--seed-contents--
--fcc-editable-region--
--fcc-editable-region--