--- id: bad87dee1348bd9aede07836 title: Usa un atributo de id para aplicar estilo a un elemento challengeType: 0 videoUrl: 'https://scrimba.com/c/cakyZfL' forumTopicId: 18339 dashedName: use-an-id-attribute-to-style-an-element --- # --description-- Una cosa genial de los atributos `id` es que, al igual que las clases, puedes aplicarles estilos con CSS. Sin embargo, un `id` no es reutilizable y solo debe aplicarse a un único elemento. Un `id` también tiene mayor especificidad (importancia) que una clase, así que si aplicas un id y una clase al mismo elemento y sus estilos se contradicen, se aplicarán los estilos del `id`. A continuación te mostramos un ejemplo de cómo puedes tomar tu elemento con el atributo `id` llamado `cat-photo-element` y asignarle el color de fondo verde. En tu elemento `style` agrega la siguiente declaración: ```css #cat-photo-element { background-color: green; } ``` Ten en cuenta que dentro de tu elemento `style` siempre debes hacer referencia a las clases agregándoles un punto `.` adelante del nombre. Para hacer referencia a un id, debes agregar `#` delante de su nombre. # --instructions-- Intenta asignar a tu formulario, que ahora tiene el atributo `id` llamado `cat-photo-form`, un fondo verde. # --hints-- Tu elemento `form` debe tener el id `cat-photo-form`. ```js assert($('form').attr('id') === 'cat-photo-form'); ``` Tu elemento `form` debe tener `background-color` de color verde (green). ```js assert($('#cat-photo-form').css('background-color') === 'rgb(0, 128, 0)'); ``` Tu elemento `form` debe tener un atributo `id`. ```js assert( code.match(//gi) && code.match(//gi).length > 0 ); ``` No debes asignar a tu `form` ningún atributo `class` o `style`. ```js assert(!code.match(//gi) && !code.match(//gi)); ``` # --seed-- ## --seed-contents-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

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:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```