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.

1 Like

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.

1 Like

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.

hello guys
can you help me pleaseeee?
i test my website in w3 validator and this site show me a lot of errors.
this link is: https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.meroeh.com%2F
my website name is: https://www.meroeh.com
so, i understand these errors but i can not find the file which has that errors for editing.
can you help me to find one of this file for editing and solve error to understand to solve these errors?

Very good it was helpful