Trouble with CSS image format

Hi. My exercise test gives me these messages:

  • Failed: Your img element should have a display of block.
  • Failed: Your #image should have a max-width of 100%.
  • Passed: Your #image should have a height of auto.
  • Failed: Your #image should be centered within its parent.

While my code looks like this:

img {
max-width: 100%;
display: block;
max-height: 70vh;
margin: 0 auto;
}

What’s going on?

Hello, post the link to this exercise please.

You need this too # its the id symbol +img.

Do you mean that I should refer to the image element by the id? Can you demonstrate, please? I don’t see what you mean.

On mine It has this #image so in this case yes.

The test doesn’t accept that either:

#image {
max-width: 100%;
display: block;
max-height: 70vh;
margin: 0 auto;
}

And yes, my html does have the id.

You can try to remove max-height: 70vh; margin: 0 auto; and replace with height of auto, if that dosnt work post all your html and css. do you have img- caption as well?

How do I post the code? I am not allowed to have any links in it or something.

You could just select all and paste but do html and css one at a time. They recommend three backticks before and after but I dont think this is big enough.

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="style.css">
	<title>Tribute page project</title>
</head>

<body>
	<main id="main">
		<h1 id="title">Person's name</h1>
		<p>Tribute text</p>
		<figure id="img-div">
			<img id="image" src="https://images.unsplash.com/photo-1526547541286-73a7aaa08f2a?q=80&w=1000&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxleHBsb3JlLWZlZWR8Mnx8fGVufDB8fHx8fA%3D%3D" alt="Description" />
			<figcaption id="img-caption">Tribute caption text</figcaption>
		</figure>
		<h2>Tribute information:</h2>
		<ul id="tribute-info">
			<li>Item 1</li>
			<li>Item 2</li>
			<li>Item 3</li>
			<li>Item 4</li>
			<li>Item 5</li> 
		</ul>
		<blockquote cite="https://www.google.com/">
			<p>"Quote"</p>
			<footer>– Person, <cite><a target="_blank" href="https://www.google.com/">here</a></cite></footer>
		</blockquote>		
		<h3>Some more text <a id="tribute-link" target="_blank" href="https://www.google.com/"><cite>link</cite></a>, and more text<h3>
	</main>
</body>

</html>
html {
    font-size: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 1.7rem;
    line-height: 1.5;
    text-align: center;
    margin: 0;
}

h1 {
    font-size: 4rem;
    margin-bottom: 0;
}

@media (max-width: 460px) {
    h1 {
        font-size: 3rem;
        line-height: 1;
    }
}

h2 {
    font-size: 2rem;
    margin: 50px 0 0 0;
}

@media (max-width: 460px) {
    h2 {
        margin: 20px 0 0 0;
        line-height: 1;
    }    
}

a {
    color: cornflowerblue;
}

a:visited {
    color: blueviolet;
}

main {
    margin: 30px 8px;
    padding: 15px;
    border-radius: 5px;
    background-color: whitesmoke; 
}

@media (max-width: 460px) {
    main {
        margin: 0;
        line-height: 1.1;
    }
}

#image {
    max-width: 100%;
    display: block;
    max-height: 70vh;
    margin: 0 auto;
}

#img-div {
    background: white;
    padding: 10px 0;
    margin: 0;
}

#img-caption {
    font-size: 1.5rem;
    margin: 15px 0 5px 0;
}

@media (max-width: 460px) {
    #img-caption {
        font-size: 1.4rem;
    }    
}

ul {
    max-width: 550px;
    margin: 50px auto 50px auto;
    text-align: left;
}

@media (max-width: 460px) {
    ul {
        margin: 20px auto 20px auto;
        line-height: 1.1;
    }    
}

li {
    margin: 16px 0;
}

blockquote {
    font-style: italic;
    max-width: 545px;
    margin: 0 auto 50px auto;
    text-align: left;
}

h3 {
    font-size: 1.7rem;
}

I have tried all your suggestions, and experimented with it myself, with no luck.

Hi @teddybeard

Try adding an s to the end of the file name.

Happy coding

Oh, my, GOD! xD
I don’t believe this…