Почему валидатор выдает ошибку?
Прохожу курс на htmlacademy, пытаюсь отправить проект на защиту, но не пропускает автоматический валидатор, причем выдает ошибки, которых нет.
P.S. наставники уже не помогают.
1. Пишет, что не указана кодировка, хотя она указана как на странице, так и в атоме, в котором пишу. Везде utf-8.
Так же выдает, что этот тег не закрыт. Пробовал написать его так , все равно пишет, что не закрыт и еще дополнительную ошибку на этот символ.
Еще пишет Bad element name “meta-charset=»utf-8″”: Code point “U+003D” is not allowed
2.Выдает ошибку в нескольких местах «Unmappable byte sequence: “81”. «. Что это означает понять не могу, первое слово вообще даже переводчик не берет.
3. Element “head” is missing a required instance of child element “title”. Так же не могу понять в чем ошибка, код выше.
4. Element “title” not allowed as child of element “meta-charset=»utf-8″” in this context.
Титульный элемент не допускается как дочерний к meta-charset.
Так же не понятно как исправить в связи с вопросами выше.
5. Stray end tag “head”. Переводчик перевел это как «шальное закрытие тега head. Это как понять? Код выше.
6. Start tag “body” seen but an element of the same type was already open. «Начальный тег body виден, но элемент того же типа уже открыт». Но у меня один на странице и он закрыт!
7. End tag for “body” seen, but there were unclosed elements. Говорит о незакрытых элементах, прошелся про каждому — нет незакрытых!
Stray end tag "head"
The code is inside the html tag. I don’t understand the reason of this error, I close all tags except for meta and link, which can’t be closed, what’s the problem?
7 Answers 7
you need to understand — the <head> element defines attributes that are used by the browser, but are not directly visible in the page. The <title> attribute defines the title shown on your browser tab.
After you close the <head> tag, you should open the <body> tag, in which all the content to be shown in the page should go.
False positive for stray end tags #841
The Nu HTML Checker reports two stray end tags on this page, but both have corresponding start tags.
Error: Stray end tag noscript.
From line 142, column 70; to line 142, column 80
/FONT></B></noscript>↩ <
LL comment: The start tag is on the same line as the end tag (142).
Error: Stray end tag head.
From line 144, column 3; to line 144, column 9
script>↩ </head>↩ <bo
LL comment: The start tag is on line 1.
The text was updated successfully, but these errors were encountered:
For https://www.w3.org/WAI/demos/bad/before/home.html , I suspect it’s related to the <noscript> containing illegal children due to it being within the <head> . Probably that causes the parser to implicitly close the <noscript> tag early, thus making the explicit close </noscript> tag extraneous.
- In a head element, if scripting is disabled for the noscript element
- The noscript element must contain only link , style , and meta elements.
- The noscript element must contain only text, except that invoking the HTML fragment parsing algorithm with the noscript element as the context element and the text contents as the input must result in a list of nodes that consists only of link , style , and meta elements that would be conforming if they were children of the noscript element, and no parse errors.
<b> and <font> aren’t among the permitted children.
Ok, so not exactly a false positive, but rather a false attribution.
Hm. If the problem is that a <noscript> in a <head> can’t contain <b> or <font> elements, shouldn’t removing the <b> and <font> elements from the <noscript> prevent the «stray end tag» error? It doesn’t.
Hm. If the problem is that a <noscript> in a <head> can’t contain <b> or <font> elements, shouldn’t removing the <b> and <font> elements from the <noscript> prevent the «stray end tag» error? It doesn’t.
Can you doublecheck that?
Here is minimal test case:
That one has <b> in <noscript> , which makes the checker report Stray end tag noscript :
Here is another minimal test case:
That one has no <b> in <noscript> , and the checker reports no errors:
For https://www.w3.org/WAI/demos/bad/before/home.html , I suspect it’s related to the <noscript> containing illegal children due to it being within the <head> . Probably that causes the parser to implicitly close the <noscript> tag early, thus making the explicit close </noscript> tag extraneous.
That is exactly the case. But it’s important to note that you’ll only see that behavior when scripting is disabled (as mentioned in the spec section you cited).
When scripting is not disabled — which of course in the normal case in web browsers — then the parser actually won’t implicitly close that noscript element. More specifically, when scripting is not disabled, the <B><FONT COLOR=RED>This page uses scripts. </FONT></B> inside the NOSCRIPT element in the source of https://www.w3.org/WAI/demos/bad/before/home.html just goes into the DOM as a text node.
But the checker is not capable of checking documents with scripting enabled. The checker doesn’t have a JavaScript engine to execute script with. So the checker uses the HTML parser in “scripting disabled” mode. And in “scripting disabled” mode, the parser doesn’t evaluate the NOSCRIPT content as text — instead the parser tries to parse any markup it finds inside the NOSCRIPT .
So exactly what happens here is that when the parser hits that <b> start tag, the parser inserts an implicit </noscript> end tag before the <b> start tag. But the parser doesn’t stop there; because the b element cannot appear in head , the parser also inserts both an implicit </head> end tag before the <b> start tag, and also inserts an implicit <body> start tag.
So with scripting disabled, this is what the parser ends up putting into the DOM:
Stray end tag head как исправить
Group: Members
Posts: 1
Joined: 18-November 20
Member No.: 27,645I am using https://validator.w3.org/ to check my html markup. And it shows this weird error. Does anyone know how to fix this?
(Stray end tag head.) & (Start tag body seen but an element of the same type was already open.)<a href="https://callservicing.com/dentist">Dentist</a>
<a href="https://callservicing.com/privacy2">Privacy Policy</a>
<a href="https://callservicing.com/termsofuse">Terms of Use</a>
<a href="https://callservicing.com/">Home</a>Computer says no
Group: WDG Moderators
Posts: 20,431
Joined: 9-August 06
Member No.: 6You've placed a lot of elements that belong in BODY in HEAD. All of this (I keep the closing HEAD tag).
The BODY tags aren't mandatory to use. If they aren't used they are implied. Same with the HEAD tags. When it sees the first A tag above the validator assumes there are both a closing tag for HEAD and a start tag for BODY before it. Then when it comes to the the end tag for HEAD and start tag for BODY you actually typed, it reports them as erroneous.
This may seem backwards, but the validator is just a machine. It takes it line for line. When it sees the A tag up in head it doesn't see an error, because HEAD and BODY tags can be implied. The error exists first when it encounters your closing tag for HEAD. It's often this way. The validator points out the point where the error i obvious to it, but the actual mistake can be much higher up in the HTML. One gets used to the validators way of "thinking" fairly quickly, because it's actually logical, even if that can be hard to see when one is new to it.
Just place those links and the list where they belong and the errors will go away.