--- id: bad87eee1348bd9aede07836 title: Impostare l'id di un elemento challengeType: 0 videoUrl: 'https://scrimba.com/c/cN6MEc2' forumTopicId: 18279 dashedName: set-the-id-of-an-element --- # --description-- Oltre alle classi, ogni elemento HTML può avere anche un attributo `id`. Ci sono diversi vantaggi ad usare gli attributi `id`: puoi usare un `id` per stilizzare un singolo elemento, e in seguito imparerai che puoi usarli per selezionare e modificare elementi specifici con JavaScript. Gli attributi `id` dovrebbero essere unici. I browser non applicano questa regola rigorosamente, ma è una buona pratica largamente accettata. Quindi non dare a più di un elemento lo stesso attributo `id`. Ecco un esempio di come fornire al tuo elemento `h2` l'id di `cat-photo-app`: ```html

``` # --instructions-- Dai al tuo elemento `form` l'id `cat-photo-form`. # --hints-- Il tuo elemento `form` dovrebbe avere l'id di `cat-photo-form`. ```js assert($('form').attr('id') === 'cat-photo-form'); ``` # --seed-- ## --seed-contents-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


``` # --solutions-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```