freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-basic-css-by-building.../5f344f9c805cd193c33d829c.md

70 lines
1.3 KiB
Markdown

---
id: 5f344f9c805cd193c33d829c
title: Step 11
challengeType: 0
dashedName: step-11
---
# --description--
Puoi aggiungere uno stile a un elemento specificandolo nell'elemento `style` e impostando una proprietà in questo modo:
```css
elemento {
proprietà: valore;
}
```
Centra l'elemento `h1` assegnando alla proprietà `text-align` il valore `center`.
# --hints--
Dovresti avere un selettore `h1` nell'elemento `style`.
```js
const hasSelector = new __helpers.CSSHelp(document).getStyle('h1');
assert(hasSelector);
```
La proprietà `text-align` dovrebbe avere il valore `center`.
```js
const hasTextAlign = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['text-align'] === 'center');
assert(hasTextAlign);
```
Il selettore `h1` dovrebbe assegnare alla proprietà `text-align` il valore `center`.
```js
const h1TextAlign = new __helpers.CSSHelp(document).getStyle('h1')?.getPropertyValue('text-align');
assert(h1TextAlign === 'center');
```
# --seed--
## --seed-contents--
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Cafe Menu</title>
--fcc-editable-region--
<style>
</style>
--fcc-editable-region--
</head>
<body>
<main>
<h1>CAMPER CAFE</h1>
<p>Est. 2020</p>
<section>
<h2>Coffee</h2>
</section>
</main>
</body>
</html>
```