Tell us what’s happening:
Describe your issue in detail here. Please assist I am stuck, How do I centre within the parent?
Your code so farmain div img{display:block;}
image{max-width:100%;
height: auto;}
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en"
<html>
<meta charset="UTF-8"
<link rel="stylesheet"href="styles.css">
<main id="main"><nav id="title">FreecodeCamp</nav>
<div id="img-div"><img id="image"><figcaption id="img-caption">FreecodeCamp Description<p id ="tribute-info">People can learn coding<a id="tribute-link"target="_blank"href="https.freecode.com"</a></p></main>
</html>
/* file: styles.css */
img{display:block;}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Challenge: Tribute Page - Build a Tribute Page
Link to the challenge:
CSS-Tricks: Centering in CSS: A Complete Guide
Since you are turning the img
element into a block display then an easy method would be to use auto side margins.
type or paste code here#image{img {display:block;}
{margin:auto;}}
#image{max-width:100%;}
{height: auto;}
its still giving error
type or paste code here img{display:block;}
{margin: auto;}
image{max-width:100%;}
{height: auto;}
Slightly better but still not valid CSS. All rulesets need to have a selector.
{margin: auto;}
This is invalid because you haven’t specified what element(s) it should apply to.
ok, I have specified it to the img element, but the error message keeps coming up.
type or paste code here img{display:block;
margin: auto;}
image{max-width:100%;}
{height: auto;}
You are getting closer. You’ve got an HTML problem you need to fix.
I have added the closing tag, same error.
type or paste code here <meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
I’m assuming are referring to this failing test?
“Your #image
should have a max-width
of 100%
.”
Show me in your CSS where you are setting max-width
to 100%
on the #image
element.
1 Like
I have corrected it. Thanks a lot.
system
Closed
12
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.