php — WP : Stray start tag HTML in validator?
Get the solution ↓↓↓
I am trying to validate this HTML document in http://validator.w3.org/#validate_by_input but I am getting the following errors:
This is the HTML I am inputting:


Answer
Solution:
The <meta> tag here implies an additional <html> and <head> tag before.
According to the HTML5 standard some tags are optional. <html> and <head> are such tags. You can drop them, but the parser will insert them, where needed. In your case they are needed before the <meta> tag, because <meta> is defined as a child element to the <head> tag, which in turn is a child of <html> .
So what the validator actually sees is this:
Now it is obvious, why it complains about the «second» <html> tag.
The solution would be to just change the ordering of your tags. Put the <html> and <head> tag before the <meta> tag, and you should be fine.
Share solution ↓
Additional Information:
Didn’t find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
About the technologies asked in this question
PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
HTML (English «hyper text markup language» — hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.
Stray start tag div
I am trying to fix my code after validating the code according to international standard:
Error: Stray start tag div.
From line 180, column 1; to line 180, column 20
- 2 Contributors
- 1 Reply
- 2K Views
- 2 Hours Discussion Span
- Latest Post 7 Years Ago Latest Post by cereal
move the </body> tag to the end of the page, just before the </html> tag. An HTML document is composed two main sections, head and body:
The head section is used to define the document type, encoding and the resources to load such as scripts, fonts and styles possibly before rendering the content of the body section. Whatever you don’t code inside the head section must to be placed in the body section. You must not write code outsite of these boundaries.
We’re a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.
Reach out to all the awesome people in our ui / ux design community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.
Getting error about a stray start tag that I simply can't figure out
When I inspect the HTML with Firebug, the span tag is not there. If I look at the page source, via Firefox, the span start tag and end tag are displayed in red indicating that something is wrong.
Hovering the cursor over the red code gives me: Stray start tag «span»
If I run the page through a validator, no errors are found.
Perhaps a span tag is not allowed in a option tag.
But then, why doesn’t the validator not flag it.
EDIT * * * * NIX THE BIT ABOUT THE VALIDATOR, I just looked again and found I was using the CSS validator.
I ran the page through the markup vaidator and got:
Error: Stray start tag span.
From line 273, column 80; to line 273, column 134
m=201512′><span style=»text-decoration: underline; color: blue;»> Decem
Answers
MDN Option:
Permitted content Text with eventually escaped characters (like é).
No spans are permitted, it is text only. If you want to style the text, you need to look at a JavaScript/CSS solution that is not a standard element.

If you’re inserting text content in your document in a location where text content is expected 1 , you typically only need to escape the same characters as you would in XML. Inside of an element, this just includes the entity escape ampersand & and the element delimiter less-than and greater-than signs < > :
Inside of attribute values you must also escape the quote character you’re using:
In some cases it may be safe to skip escaping some of these characters, but I encourage you to escape all five in all cases to reduce the chance of making a mistake.
If your document encoding does not support all of the characters that you’re using, such as if you’re trying to use emoji in an ASCII-encoded document, you also need to escape those. Most documents these days are encoded using the fully Unicode-supporting UTF-8 encoding where this won’t be necessary.
In general, you should not escape spaces as . is not a normal space, it’s a non-breaking space. You can use these instead of normal spaces to prevent a line break from being inserted between two words, or to insert extra space without it being automatically collapsed, but this is usually a rare case. Don’t do this unless you have a design constraint that requires it.
1 By «a location where text content is expected», I mean inside of an element or quoted attribute value where normal parsing rules apply. For example: <p>HERE</p> or <p title=»HERE»>. </p> . What I wrote above does not apply to content that has special parsing rules or meaning, such as inside of a script or style tag, or as an element or attribute name. For example: <NOT-HERE>. </NOT-HERE> , <script>NOT-HERE</script> , <style>NOT-HERE</style> , or <p NOT-HERE=». «>. </p> .
In these contexts, the rules are more complicated and it’s much easier to introduce a security vulnerability. I strongly discourage you from ever inserting dynamic content in any of these locations. I have seen teams of competent security-aware developers introduce vulnerabilities by assuming that they had encoded these values correctly, but missing an edge case. There’s usually a safer alternative, such as putting the dynamic value in an attribute and then handling it with JavaScript.
If you must, please read the Open Web Application Security Project’s XSS Prevention Rules to help understand some of the concerns you will need to keep in mind.
Бродячий стартовый тег html и head
Я — новый программист, работающий над моим первым сайтом RoR (с внедренной темой начальной загрузки) и имеющий некоторые (кажущиеся простыми) проблемы с HTML, замеченные с проблемами обмена изображениями через отладчик facebook. Ошибка говорит: «У вашей страницы есть метатеги в теле вместо заголовка. Это может быть потому, что ваш HTML был искажен, и они упали ниже в дереве разбора. Пожалуйста, исправьте это, чтобы теги можно было использовать «.
Я тестировал на http://validator.w3.org/ с HTML5. Вот две ошибки, которые мне особенно интересны:
Некоторое время назад я исследовал это и нашел много похожих вопросов: начальный тег Stray html, начальный тег Stray в валидаторе? Ошибка начального тега, получение «HTML-кода конечного тега» из W3C Validator, хотя никто не решил мою ситуацию. Я считаю, что у меня правильный формат HTML5:
Мне любопытно, если «no-js» или div id оказывают влияние и не нашли большой помощи в этом отношении.
Мой вопрос: что такое уродливый HTML? В частности, как я могу исправить ошибки блуждающего начального тега html и блуждающего начального тега, заданные валидатором HTML (чтобы в конечном итоге исправить ошибку отладчика facebook и отобразить правильное изображение)?