---
id: 61537d86bdc3dd343688fceb
title: Step 4
challengeType: 0
dashedName: step-4
---

# --description--

Next, give each `img` a `src` attribute according to its order in the document. The first `img` should have a `src` of `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/1.jpg`. The rest should be the same, except replace the `1` with the number the `img` is in the document.

# --hints--

All nine of your `img` elements should have a `src` attribute.

```js
const images = [...document.querySelectorAll('img')];
assert.isTrue(images.every(image => image.getAttribute('src')));
```

Your first `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/1.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[0]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/1.jpg');
```

Your second `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/2.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[1]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/2.jpg');
```

Your third `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/3.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[2]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/3.jpg');
```

Your fourth `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/4.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[3]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/4.jpg');
```

Your fifth `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/5.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[4]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/5.jpg');
```

Your sixth `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/6.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[5]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/6.jpg');
```

Your seventh `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/7.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[6]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/7.jpg');
```

Your eighth `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/8.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[7]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/8.jpg');
```

Your ninth `img` element should have `https://cdn.freecodecamp.org/curriculum/css-photo-gallery/9.jpg` set as the `src` attribute value.

```js
assert.equal(document.querySelectorAll('img')?.[8]?.getAttribute('src'), 'https://cdn.freecodecamp.org/curriculum/css-photo-gallery/9.jpg');
```

# --seed--

## --seed-contents--

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Photo Gallery</title>
    <link rel="stylesheet" href="./styles.css">
  </head>
  <body>
    <header class="header">
      <h1>css flexbox photo gallery</h1>
    </header>
--fcc-editable-region--
    <div class="gallery">
      <img>
      <img>
      <img>
      <img>
      <img>
      <img>
      <img>
      <img>
      <img>
    </div>
--fcc-editable-region--
  </body>
</html>
```

```css

```
