What is "Trailing slash on void elements has no effect"?

Hi, there,

I am an absolute beginner. When I validated my first html file, it says:
Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.

What does this mean?

Thanks in advance.

Hi Ivan,
provide your html code!

It is referring to the forward slash at the end of the element.

Elements can have either an opening and closing tag, or just a single tag. When you have a single tag it is referred to a void because there is no content. Content is the text you place between opening and closing tags, ‘<h1>content</h1>‘.

That validator is set to give you a warning about using a forward slash with a void (single tag) element.

Thanks for reply.

It turns out that I’ve used Pretir and enable “Format on save”. So each time I save, Pretir adds a a forward slash(/) automatically. That’s why the validator reports a warning.

But if I delete the forword slash, the validator does not report the warning.

So I am even more confused as to what’s the problem.

Which is Ok: with / or without / ?

Or it doesn’t matter at all.

Many thanks.

Thanks. Please see the below.

There is a longer explanation, but just to keep it to the point…it does not matter. HTML does not require the slash, and it is letting you know that if you use it and do not surround your attribute values in double quotes then you could have some issues, but you don’t have any issues right now. Think of it as trying to give you advice rather than a warning that you are doing something wrong with what you have.

I quit using prettier cause I prefer to format myself. If it is something you prefer to use then it will be something you just have to ignore.

Thanks again. Quiting prettier is a good solution.