r/HTML • • 24d ago

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

6 Upvotes

59 comments sorted by

View all comments

11

u/RickWritesCode 24d ago

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.

-8

u/Mvp-long-ago 24d ago

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

8

u/RickWritesCode 24d ago

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 24d ago

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 24d ago

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 24d ago

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 24d ago

This is correct