Sizing My Image

Sizing My Image
0

#1

Tell us what’s happening:
I added a class to my HTML element. Is there something wrong with Google Chrome?

Your code so far


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, monospace;
  }

  p {
    font-size: 16px;
    font-family: monospace;
  }
 <h2 class ="smaller image">CatPhotoApp</h2> {
    width: 100px
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>
<main>
  <p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
  
  <a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
  
  <div>
    <p>Things cats love:</p>
    <ul>
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
    <p>Top 3 things cats hate:</p>
    <ol>
      <li>flea treatment</li>
      <li>thunder</li>
      <li>other cats</li>
    </ol>
  </div>
  
  <form action="/submit-cat-photo">
    <label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
    <label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
    <label><input type="checkbox" name="personality" checked> Loving</label>
    <label><input type="checkbox" name="personality"> Lazy</label>
    <label><input type="checkbox" name="personality"> Energetic</label><br>
    <input type="text" placeholder="cat photo URL" required>
    <button type="submit">Submit</button>
  </form>
</main>

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/basic-css/size-your-images


#2

First, you need to define smaller-image class inside your style tags.

Then apply it to your h2 element with correct spelling.


#3

Could you please show me an example?


#4

You add this to your style:

.smaller-image {
          width: 100px;
}

And modify your HTML code to look like this:

 <h2 class ="smaller-image">CatPhotoApp</h2> 

Please note that you cannot define classes outside of CSS or tag and also, be extra careful with the typing and naming. smaller image is VERY different from smaller-image when it comes to computer code.


#5

Thank you for the example, for it’s easy to forget how to do certain lines of code. I followed your code to a T, but I still can’t get past this part. My browser zoom is at 100%. What else should I do?


#6

You need to add that class to the image, not to the H2 tag.

h1 - h6 are for text.

Create this class in your style tags

.smaller-image {
width: 100px;
}

Go to your
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>

and change it to

<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" class="smaller-image" alt="A cute orange cat lying on its back."></a>

You have to create the class inside the <style></style> tags. The class then needs to be added to the element you wish to modify, in this case the <img> and not to the <h2></h2>

Hope it helps,
Dan


#7

I can not pass this too, I can not understand what @WaterlooPitt try to say, It’s so complex


#8

Nvm, i passed it. Thank you


#9

Style element recognizes CSS code.
You should not put this line in your style element

<h2 class ="smaller image">CatPhotoApp</h2> {
    width: 100px
  }

instead change it to

.small-image {
   width: 100px
 }

because this line of code: <h2 class ="smaller image">CatPhotoApp</h2> is HTML code not CSS code.
In order to pass you have to add a class name to your image element and name it small-image.
Change this part of your HTML code:

<img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">

to

<img class="small-image" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">

By naming your img element small-image, your CSS style on top should be able to resize your image.


#10

@nguyen.hai38
Sizing My Image ← This is the explanation about what’s wrong with the original question.

You can’t write HTML inside a style element. You have to write in CSS inside the <style> tag and use

  • selectors like .small-image for classes and #title-div for id's.
  • pseudo-selectors like :hover.