--- id: bad87eee1348bd9aede07836 title: Set the id of an Element challengeType: 0 videoUrl: '' localeTitle: 设置元素的id --- ## Description
除了类之外,每个HTML元素还可以具有id属性。使用id属性有几个好处:您可以使用id来设置单个元素的样式,稍后您将学习如何使用它来使用JavaScript选择和修改特定元素。 id属性应该是唯一的。浏览器不会强制执行此操作,但这是广泛认可的最佳实践。所以请不要给多个元素赋予相同的id属性。这里有一个例子,说明如何为你的h2元素提供cat-photo-app <h2 id="cat-photo-app"><h2 id="cat-photo-app">
## Instructions
form元素添加id cat-photo-form
## Tests
```yml tests: - text: 为form元素添加cat-photo-form的id。 testString: 'assert($("form").attr("id") === "cat-photo-form", "Give your form element the id of cat-photo-form.");' ```
## Challenge Seed
```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


```
## Solution
```js // solution required ```