r/HTML • • Sep 19 '26

What am I doing wrong?

Post image

No matter what numbers I enter, I always get it wrong. I even used smaller numbers for height and larger for width incase they got it mixed up. Their AI is telling me to do everything I am already doing

5 Upvotes

59 comments sorted by

25

u/mondayquestions Sep 19 '26

Do they want you to use the values on the bottom of the screen (300 and 220)?

11

u/RickWritesCode Sep 19 '26

This isn't xhtml. Image tags are self closing, stop giving bad advice. Use the numbers in the bottom and see if that does it.

-9

u/Mvp-long-ago Sep 19 '26

But to make a real correct html document you should at least close the img tag with /

10

u/RickWritesCode Sep 19 '26

Html5 is the standard, you do not close void or self contained tags. Closing breaks and image and self contained tags is left over ideology from xhtml where it was required.

-2

u/404IdentityNotFound Sep 19 '26

Doesn't HTML5 just say that you don't HAVE to close void elements? You are not wrong in doing so (I do because it helps me mentally connect start and end easier)

2

u/UniqueUsername014 Sep 19 '26

From Void element on MDN:

In HTML, a void element must not have an end tag.

The /> syntax is technically valid, but it means the same thing as just >. The element <div /> is an open div, not the same as <div></div>.

For a longer writeup regarding using the self-closing tags for formatting purposes, see  The case against self-closing tags in HTML

1

u/RickWritesCode Sep 19 '26

It states it functionally does nothing therefore is not required. You may run into issues if you use multi-language code bases not using it. But for someone learning HTML for the first time they do not need to learn rules for react.

-1

u/a2annie Sep 19 '26

This is correct

5

u/Dragenby Sep 19 '26

Missing the alt tag

1

u/ahallicks Sep 19 '26

*attribute

0

u/gulliverian Sep 19 '26

You say "I always get it wrong". What does that mean? What result are you getting?

5

u/Everything_A Sep 19 '26

Alt is mandatory, right?

1

u/l008com Sep 19 '26

According to the validator it is.

-9

u/Mvp-long-ago Sep 19 '26

Alt is not mandatory

6

u/Dragenby Sep 19 '26

1

u/Jonny10128 Sep 20 '26

u/testingaurora u/Dragenby

I think the alt attribute being required depends on which browser you are using. I used the code editor baked into the Mozilla page Dragenby linked, and it successfully displayed an image only using the src attribute and no others. I am using Safari on iOS fwiw

1

u/Dragenby Sep 20 '26

It's not because it's displaying that it's correct. Put your code in the W3C validator to detect errors.

1

u/Jonny10128 Sep 20 '26

I would argue that it is recommended and not required. If browsers will display it without the alt attribute, I would not say it’s required

1

u/Dragenby Sep 20 '26

HTML is not a display language, but a semantic language. There are tons of things that isn't for display but are mandatory. The Doctype, the language in the html tag, the alt in the image tag, and so on

1

u/Mvp-long-ago Sep 20 '26

It is also depending on how a webpage or document is declared. A browser sees everything as text at first glance, until it is declared what type of document it is. That can be declared in doctype as i recall. Besides HTML, it could be a video, an image, a XML document or something else. As an attribute of declaring the doctype you can also declare how a broswer should handle a document. If you say strict, it must handle according to the rules that you have declared earlier. Mostly used with XML documents

1

u/testingaurora Sep 20 '26

Its not browser specific, its a lamgiage requirement. Yes the tag will display the image without it, html is forgiving but its still required in the spec. Same way you don't close an <img></img> tag but it will still work.

The required alt attribute specifies an alternate text for an image, if the image cannot be displayed c

The alt attribute must be specified for the IMG and AREA elements. It is optional for the INPUT and APPLET elements. c

Just get in the habit of adding alt="", and then work on learning how to write alt text, and when its necessary , when its not (in which case a background-image may be a better choice)

3

u/testingaurora Sep 19 '26

Alt is a required attribute even if its empty alt=""

1

u/ajamdonut Sep 19 '26

220 height 120 width

1

u/gulliverian Sep 19 '26

You say "I always get it wrong". What does that mean? What result are you getting?

1

u/koqkpa Sep 25 '26

Why not try swap the positions of the height and width attribute?

<img src="/img/clawdius.png" width="120' height="350">

1

u/a2annie Sep 19 '26

Best not to make up numbers for the size of your image. Find out what size it actually is.

And close your image tags. What does this mean? Right before your end bracket add the ending slash. There’s a space then />

Take an HTML class from a human too.

7

u/RickWritesCode Sep 19 '26

Image tags are self closing, this isn't xhtml. You probably close break tags too don't you?

1

u/a2annie Sep 19 '26

They are self closing, yes.

2

u/Consibl Sep 19 '26

I think this is it - the values need to be in the correct ratios for the actual image maybe?

3

u/gulliverian Sep 19 '26

no, the image will be distorted if the ratio is wrong, but it will appear.

1

u/a2annie Sep 19 '26

Exactly. Unless it’s the same ratio. Then it will appear correctly, just not optimized.

1

u/SecretLecture3219 Sep 19 '26

As previous commentor do you not need to correctly place all the values given at the bottom?

1

u/xMcCreamyx Sep 19 '26

What learning app is that?

2

u/Warm-Tea6882 Sep 19 '26

It's mimo. It's a great app for learning coding.

3

u/tangerinelion Sep 20 '26

... doesn't look like it's good.

1

u/Warm-Tea6882 Sep 20 '26

Lol I don't know why OPs mimo is having problems but it works fine for me .

-4

u/ThisIsMB Sep 19 '26

Didn’t finish the img tag

-3

u/nonchip Sep 19 '26

not using the tokens you were given.

also, using an "ai" as a teacher.

also, depending on what kind/version of html this is, you need to either close the tag or mark it empty using a slash.

-2

u/kewcumber_ Sep 19 '26

Not at all good with html but maybe because you're missing the alt attribute?

-1

u/l008com Sep 19 '26

No units? 350 what?

Also in real life, we stopped putting the height and width in the html like 15 to 20 years ago.

1

u/Lithl Sep 20 '26

The height/width attributes do not accept units. They are always measured in pixels.

Using CSS is best practice over specifying dimensions in attributes, and CSS requires units, but OP is just learning HTML.

1

u/ArgoWizbang Sep 20 '26

Using CSS is best practice over specifying dimensions in attributes

The attributes absolutely should still be used, mostly because the attributes' main uses are not for styling but rather to help prevent layout shift. Having that information directly available in the <img> tag allows the browser to quickly determine the image's aspect ratio and properly reserve space for the image before it finishes downloading thus reducing CLS. Then CSS comes into effect and determines how the image should actually be displayed. Sure, you can set the aspect ratio in the CSS instead but if you already for sure know the image's proper dimensions then putting that information in the HTML as well is just a good practice to hold on to.

0

u/RushDangerous7637 Sep 19 '26

Correct have two options:

<img src="/img/clawdius.png" width="120" height="350" alt="clawdius" />
<img src="https://yourdomain.com/img/clawdius.png" width="120" height="350" alt="clawdius" />

In the notation, width must always come first, followed by height as the second dimension. Don't forget to fill in the alt="a-keyword-will-help-the-websites-ranking"

0

u/5omething5trange Sep 20 '26

Css have to be in style tag?

1

u/Own_Natural_6803 Sep 21 '26

Not for everything. Something's like images have built-in attributes which are related to display.

But it's generally considered best practice to put things inside of a CSS sheet. 

-6

u/cloudstrifeuk Sep 19 '26

You haven't closed/finished the img tag.

-4

u/Ronin-s_Spirit Sep 19 '26

try putting a forward slash there.

-6

u/Carlss32 Sep 19 '26

You always need to add the closing tag of each html elements, this one "/>"

For example. <img/>

7

u/RickWritesCode Sep 19 '26

Image tags are self closing, this isn't xhtml

3

u/Carlss32 Sep 19 '26

Best comment I ever had. I never expected to have negative points, though. I just give my thoughts what would be an issue, to help as fellow. To be honest, the return error is confusing that led me this way. Also the stack I used to enforce it, react with eslint. That's why I assumed it to be a culprit as well. Never been used plain html5 in my project.

1

u/Mvp-long-ago Sep 19 '26

Is XHTML HTML strict? So strictly according to the rules?

2

u/RickWritesCode Sep 19 '26

26 years ago this was a requirement when w3c made xhtml the standard, 2008 and final publication in 2014 html5 is the standard and dropped this requirement. Prior to 2000, it also was not required to close self contained tags

1

u/Lithl Sep 20 '26

No, XHTML is XHTML.

-5

u/obnoxus Sep 19 '26

its telling you to finish the tag and as far as i can tell it isn't finished.

0

u/[deleted] Sep 19 '26

[deleted]

1

u/DidTooMuchSpeedAgain Sep 19 '26

That's not inline CSS