Stray start tag html как исправить

I cannot work out why I am getting this error:

Stray start tag footer.

This is the code (I took the content out, this is just the tags)

<!doctype html>

<head>
    <title>title</title>
    <meta charset="UTF-8">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
    <img src="heading.jpg" width="840" alt="pic">
    <!--<div id="container"></div> used ot set width of page -->
    <nav>
        <div id="columns">
            <a href="index.html">Home</a>
            <a href="products.html">Products</a>
            <a href="gift_ideas.html">Gift Ideas</a>
        </div>
        <br>
        <div id="link">
            <a href="link1.html">link1</a>|<a href="link2.html">link2</a>|<a href="link3.html">link 3</a>
        </div>
    </nav>
    <section>
        <br>
        <div id="homePage">
            <h1>Welcome</h1>
            <br>
            <div id="cart">
                <img src>
            </div>
        </div>
    </section>
</body>
<footer>
    <br>
    <h2>Contact Us</h2>
    Email: <a href="email@example.co.nz">email@example.co.nz</a>
    <img src>
</footer>

I am sure i have closed every tag, so what is the problem with the footer?

asked Sep 22, 2013 at 2:29

Hayley van Waas's user avatar

Hayley van WaasHayley van Waas

4293 gold badges12 silver badges21 bronze badges

2

You need to move the </body> end tag at the very end, because a footer element must not appear after the body element but inside it. This follows from the syntax of the root element, the html element: it contains a head element and a body element, nothing more.

The validator says “Stray start tag footer” because the start tag appears in a context where no elements can be started – after the </body> tag, where only the optional </html> tag may appear.

answered Sep 22, 2013 at 4:36

Jukka K. Korpela's user avatar

Jukka K. KorpelaJukka K. Korpela

194k36 gold badges266 silver badges387 bronze badges

Missing <html> tags added, <footer> brought inside <body> tag. While not directly related to your question, it would also appear you are using <br> tags to make space between various elements. I would suggest you stop doing that, and use CSS to adjust the margin properties of those elements instead.

Complete code below:

<!doctype html>
<html>
<head>
    <title>title</title>
    <meta charset="UTF-8">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
    <img src="heading.jpg" width="840" alt="pic">
    <!--<div id="container"></div> used ot set width of page -->
    <nav>
        <div id="columns">
            <a href="index.html">Home</a>
            <a href="products.html">Products</a>
            <a href="gift_ideas.html">Gift Ideas</a>
        </div>
        <br>
        <div id="link">
            <a href="link1.html">link1</a>|<a href="link2.html">link2</a>|<a href="link3.html">link 3</a>
        </div>
    </nav>
    <section>
        <br>
        <div id="homePage">
            <h1>Welcome</h1>
            <br>
            <div id="cart">
                <img src>
            </div>
        </div>
    </section>
    <footer>
        <br>
        <h2>Contact Us</h2>
        Email: <a href="email@example.co.nz">email@example.co.nz</a>
        <img src>
    </footer>
</body>
</html>

answered Sep 22, 2013 at 3:23

Sean Ryan's user avatar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<div class="table_index_box">
                                                <table class="table_box table uk-table table-bordered uk-width-1-1">
                                                    <colgroup>
                                                        <col span="100%">    
                                                    </colgroup>
                                                    <thead>
                                                        <tr>
                                                            
                                                                <th>
                                                                    Номер артикула
                                                                </th>
                                                                <th>
                                                                    Размеры
                                                                </th>
                                                                <th>
                                                                    Наружный диаметр
                                                                </th>
                                                                <th>
                                                                    Вес меди
                                                                </th>
                                                                <th>
                                                                    Вес кабеля
                                                                </th>
                                                            
                                                        </tr> 
                                                    </thead>
                                                    <tbody>
                                                        
                                                                                                                                                                                                                                
                                                                                                                            
                                                                     
                                                                     
                                                                        <tr>
                                                                            <td colspan="100%">
 
                                                                            </td>  
                                                                        </tr>
                                                                                                                                            
                                                                                                                                         
 
                                                                <tr>
                                                                    <td><a target="_blank" data-uk-tooltip="{pos:'top-left'}" title="Кабель OPVC-JZ/OZ-YCY 2 X 0,5 мм2" href="http://tkdkabel.ru/index.php?route=product/product&amp;path=60_64_78_152&amp;product_id=292">1001093</a></td>
                                                                    <td>2 X 0,5</td>
                                                                    <td>7,0</td>
                                                                    <td>41,0</td>
                                                                    <td>70,0</td>
                                                                </tr>
                                                                                                                                                                                            
                                                                     
                                                                                                                                        
                                                                                                                                         
 
                                                
 
                                                                <tr>
                                                                    <td><a target="_blank" data-uk-tooltip="{pos:'top-left'}" title="Кабель OPVC-JZ/OZ-YCY 2 X 0,75 мм2" href="http://tkdkabel.ru/index.php?route=product/product&amp;path=60_64_78_152&amp;product_id=300">1001092</a></td>
                                                                    <td>2 X 0,75</td>
                                                                    <td>7,5</td>
                                                                    <td>46,0</td>
                                                                    <td>83,0</td>
                                                                </tr>
                                                                                                                                                                                            
                                                                     
                                                                                                                                        
                                                                                                                                        
                                                                                                                                                                                            
                                                                     
                                                                     
                                                                        <tr>
                                                                            <td colspan="100%">
 
                                                                            </td>  
                                                                        </tr>
                                                                                                                                            
                                                                                              
 
                                                                <tr>
                                                                    <td><a target="_blank" data-uk-tooltip="{pos:'top-left'}" title="Кабель OPVC-JZ/OZ-YCY 4 G 6 мм2" href="http://tkdkabel.ru/index.php?route=product/product&amp;path=60_64_78_152&amp;product_id=335">1000705</a></td>
                                                                    <td>4 G 6</td>
                                                                    <td>15,8</td>
                                                                    <td>318,0</td>
                                                                    <td>485,0</td>
                                                                </tr>
                                                                                                                                                                                            
                                                                     
                                                                                                                                        
                                                                                                                                         
 
                                                                <tr>
                                                                    <td><a target="_blank" data-uk-tooltip="{pos:'top-left'}" title="Кабель OPVC-JZ/OZ-YCY 5 G 6 мм2" href="http://tkdkabel.ru/index.php?route=product/product&amp;path=60_64_78_152&amp;product_id=336">1000719</a></td>
                                                                    <td>5 G 6</td>
                                                                    <td>17,0</td>
                                                                    <td>441,0</td>
                                                                    <td>609,0</td>
                                                                </tr>
                                                                                                                                                                                            
                                                                     
                                                                     
                                                                        <tr>
                                                                            <td colspan="100%">
 
                                                                            </td>  
                                                                        </tr>
                                                                                                                                            
                                                                                                                                                                                                                                                         
                                                                     
                                                                                                                                        
                                                                                                                                         
 
                                                                <tr>
                                                                    <td><a target="_blank" data-uk-tooltip="{pos:'top-left'}" title="Кабель OPVC-JZ/OZ-YCY 5 G 10 мм2" href="http://tkdkabel.ru/index.php?route=product/product&amp;path=60_64_78_152&amp;product_id=338">1000715</a></td>
                                                                    <td>5 G 10</td>
                                                                    <td>21,8</td>
                                                                    <td>714,0</td>
                                                                    <td>1.105,0</td>
                                                                </tr>
                                                                                                                                                      
                                                                     
                                                                     
                                                                        <tr>
                                                                            <td colspan="100%">
 
                                                                            </td>  
                                                                        </tr>
                                                                <tr>
                                                                    <td><a target="_blank" data-uk-tooltip="{pos:'top-left'}" title="Кабель OPVC-JZ/OZ-YCY 4 G 25 мм2" href="http://tkdkabel.ru/index.php?route=product/product&amp;path=60_64_78_152&amp;product_id=340">1000700</a></td>
                                                                    <td>4 G 25</td>
                                                                    <td>28,9</td>
                                                                    <td>1.310,0</td>
                                                                    <td>1.720,0</td>
                                                                </tr>
                                                                        <tr>
                                                                            <td colspan="100%">
 
                                                                            </td>  
                                                                        </tr>
 
                                                                                                                                                                                        
                                                                                                                
                                                    </tbody>
                                                </table>

Я новый программист, работающий на моем первом сайте RoR (с внедренной загрузкой) и имеющий некоторые (казалось бы, простые) проблемы с HTML, заметил проблемы с совместным использованием изображений через отладчик facebook. Ошибка говорит: «У вашей страницы есть метатеги в теле, а не на голове. Это может быть связано с тем, что ваш HTML был искажен, и они упали ниже в дереве разбора. Пожалуйста, исправьте это, чтобы теги были пригодны для использования «.

Я тестировал на http://validator.w3.org/ с HTML5. Это две ошибки, которые мне особенно интересны:

Line 33, Column 20: Stray start tag html.
<html class="no-js">

Line 36, Column 6: Stray start tag head.
<head>

Я исследовал это некоторое время и нашел много похожих вопросов: Stray start tag html, Stray start tag HTML в валидаторе? , Stray start tag Error, Получение «Stray end tag html» из W3C Validator, хотя никто не решил мою ситуацию. Я считаю, что у меня правильный формат HTML5:

<html>
  <head>
    <meta>
    <link>
    <script></script>
    <title></title>
  </head>
  <body>
  </body>
</html>

Мне любопытно, если «no-js» или div id имеют эффект и не нашли большой помощи в этом отношении.

Мой код:

<html class="no-js">

<div id="header">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width">

    <meta property="og:title" content="one breath">
    <meta property="og:description" content="This moment is your life. Breathe. Notice it.">
    <meta property="og:image" content="http://i61.tinypic.com/2yjzpsz.png">
    <meta property="og:url" content="http://www.onebreath.io">

    <link rel="stylesheet" href="bootstrap.css">
    <link rel="stylesheet" href="bootstrap-theme.css">
    <link rel="stylesheet" href="main.css">
    <link rel="image" type="image/png" href="breathenoticeit.png">

    <script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>

    <!-- favicon -->
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">

    <title>one breath</title>
</head>
</div>

<body>
.... content ....
</body>     
</html>

Мой вопрос: что такое неправильный HTML? В частности, как я могу устранить ошибки заголовка стартового тега html и блуждающих начальных тегов, заданные модулем проверки HTML (чтобы в конечном итоге исправить ошибку отладчика facebook и отобразить правильное изображение)?

Любая помощь очень ценится! (Полный сайт www.onebreath.io)

РЕДАКТИРОВАТЬ

Уточнен вопрос.

A <head> start tag has been found in an unexpected place in the document structure. Check that the <head> section appears before the <body> section, and that is not duplicated.

The <head> section of an HTML document is the container of metadata about the document, and must appear before the <body> section. A common cause of this issue is duplicated <head> sections.

Here is an example of a minimal HTML document structure:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <p></p>
  </body>
</html>

A <script> start tag has been found in an unexpected place in the document structure. Check that the <script> section appears within the <head> or <body> sections.

Here’s an example of a script inserted in the head of the document:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
    <script>
      console.log("Hello from the head");
    </script>
  </head>
  <body>
    <p></p>
  </body>
</html>

A <style> start tag has been found in an unexpected place in the document structure. Check that the <style> section appears within the <head> section.

Although in general it’s better to put your styles in external stylesheets and apply them using <link> elements, CSS styles can also be included inside a document using the <style> tag. In this case, it should be placed within the <head> section, like in this example:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
    <style>
      p {
        color: #26b72b;
      }
    </style>
  </head>
  <body>
    <p>This text will be green.</p>
  </body>
</html>

Instead of using the isolang attribute to define the language of the document, you can use lang with an ISO 639-1 two character code.

For example, for Portuguese:

<html lang="pt">

Still checking your large sites one page at a time?

Save time using our automated web checker. Let our crawler check your web pages on the W3C Validator.

And end tag has been found that does not match the current open element. Check the context to fix the start and end tags.

An <a> tag can’t include other <a> tags inside. Most probable cause is an unclosed <a> tag, like in this example:

<a href="one.html">Page 1
<a href="two.html">Page 2</a>

25,000 HTML checks per month. Fully automated.

Save time using our automated web checker. Let our crawler check your web pages on the W3C Validator.

A <button> tag can’t include other <button> tags inside. Most probable cause is an unclosed <button> tag, like in this example:

<button>Submit
<button>Cancel</button>

HTML documents are expected to start with a first line containing the Document Type Declaration, that defines the HTML version used. Since HTML5, it’s just <!DOCTYPE html>, which must appear before the start <html> tag.

Here’s an example of a minimal HTML5 document:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <p></p>
  </body>
</html>

All HTML documents must start with a <!DOCTYPE> (Document Type Declaration), that informs browsers about the type and version of HTML used to build the document. In HTML5, this is simply <!DOCTYPE html> and must appear at the start of the document.

Here is an example of a minimal HTML document, including the Document Type Declaration at its start:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <p></p>
  </body>
</html>

An end tag for X has been found that does not correspond to a previous open tag. This usually happens when you close the same tag twice, for example:

<ul>
  <li>item</li>
</ul>
</ul>

Still checking your large sites one page at a time?

Save time using our automated web checker. Let our crawler check your web pages on the W3C Validator.

Sometimes, if you try to validate your HTML code, you can get lots of errors in your HTML code is not well structured. Sometimes it occurred when some unique tag appears multiple times in your document i.e. <HTML>, <head>, <body>. So let’s check some examples to understand them. Check the basic HTML structure here.

The <html> is a parent container tag. It should appear once in a whole document.

<!DOCTYPE html>
<html>
  <body>
	<head>
		<title>Test</title>
	</head>
    <p></p>
  </body>
</html>

Stray start tag “head”

Generally appears before the <body> tag. But if we write multiple <head> tag or <head> tag outside the <body> tag, we can get the above validation error. Check the below code to get the idea.

<!DOCTYPE html>
<html>
  
  <body>
	<head>
		<title>Test</title>
	</head>
    <p></p>
  </body>
</html>

Now check the below code in the HTML validator and you can get lots of errors.

<!DOCTYPE html>
<html>
  <body>
	<head>
		<title>Test</title>
	</head>
    <p></p>
  </body>
</html>
<HTML>
<p>Demo</p>
  • Element <head> is missing a required instance of the child element <title>. It means the <head> tag is not present after the <body> tag.
  • Stray start tag head. Already discussed above.
  • Element title not allowed as a child of element body in this context. That means we can’t use <title> inside <body>.
  • Stray start tag p. Here the <p> tag is outside the <body> tag.

A web developer who has a love for creativity and enjoys experimenting with the various techniques in both web designing and web development. If you would like to be kept up to date with his post, you can follow him.

Понравилась статья? Поделить с друзьями:
  • Как составить проект квартиры самостоятельно ремонта
  • Как найти давление газа химия
  • Как найти страдательное причастие настоящего времени
  • Что такое bmi как найти
  • Ногти загибаются вверх причины как исправить