Learn CSS Flexbox by Building a Photo Gallery - Step 7

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

I dont know what wrong iam doing with this CSS it says me to
Give your .gallery element a width of 50% and a border set to 5px solid red
so i did it as it said
and after it also says to
Then give your img elements a width of 100% , padding set to 5px , and a border set to 5px solid blue .
i dont understand here how can i give image element width and other when its not in selector please someone help me with this

<!-- file: index.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>
    <div class="gallery">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/1.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/2.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/3.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/4.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/5.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/6.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/7.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/8.jpg">
      <img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/9.jpg">
    </div>
  </body>
</html>
/* file: styles.css */

/* User Editable Region */

.gallery,img{
  width:50%;
  border:5px solid red;
  width:100%;
  padding:5px;
  border:5px solid blue;
}



/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

Learn CSS Flexbox by Building a Photo Gallery - Step 7

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

wdym by template i described my problem in my own words as easy as i could

  1. The selector asked for is .gallery

  2. You are overwritting width:50% with width:100% later in the styles. It should be width:50%

Its asking you in css to isolate just the img elements you created in your html. I tried adding class=“img” to all 9 photos in html and .img{} to css but that didn’t work. So you’ll have to separate gallery and img like this…and it worked for me.

.gallery{
  width:50%;
  border:5px solid red;
}
img{
  width:100%;
  padding:5px;
  border:5px solid blue;
}
1 Like

You need separate selector for both img and .gallery
@dynamodanish

1 Like