Max-width: 100% not working

so my parent div has → width:80%; max-width:100%;
and the actual image set the width to is → width:400px; max-width:100%; on my tribute page but it does not work even when i remove width on both

Please post a link to your full code. Also, what does “on my tribute page but it does not work” mean? What does not work?

1 Like

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

OK, now just explain “what” does not work.

Thank you. I will keep that in mind next time :slight_smile:

1 Like

My code does not pass this test:
image

It says that my image should have a max-width of 100%, which I think I am doing and at first, I thought it was because I did not set a fixed width property so I did that and tried to alter the parent div of the image as well, but I am still unable to resolve the issue. I am not sure what the problem is and why it will not pass the test case.

I will try to be more specific next time. Thank you :slight_smile:

The code you posted is passing for me. Do you have any styles in styles.css?

I would suggest not having a <style> element if you link to the styles.css stylesheet. At one point I think it was either or (I think it was fixed). In any case, you should really just put all the CSS inside styles.css

1 Like

That is very embarrassing. I noticed just now that in head i have linked to styles.css but for some reason I still went ahead and used style . I spent a long time wondering why it was not working.

Thank you very much!

I would have hoped the CSS should work regardless if it is in a style tag or the styles.css tab. Why can’t that be done to make it real-life?

It does work now, but it used to not work (as far as I remember). Now you can mix both and the styles from both get added in the correct order in the head inside style elements.

As far as I remember, at one point if you had a link to a stylesheet it would overwrite the style element in the HTML in the editor.

Oh, so it should work even if its linked to styles.css or whether its in style tag? I was not aware of that. Thank you guys very much :slight_smile: