Перейти к основному содержимому
Frontend — это бесплатный бонус CodeMentor AI; основной продукт — Python. Зарегистрируйся, чтобы сохранить прогресс и открыть все 299 уроков фронтенда + 1,100+ уроков Python.Зарегистрироваться — бесплатно
← 📄 HTML & the platform·Модуль A1 · Урок 1
ЗаданиеBuild a minimal valid HTML5 document. Doctype + html(lang='en') + head with charset + title 'Hello' + body containing an h1 with text 'Hello, world'.

Doctype и почему это необязательно

50 XP6 minFREE
Теория

What HTTP actually returns

When your backend returns HTMLResponse(content="<h1>Hi</h1>"), the browser tries to parse it. Without a doctype, it falls into "quirks mode" — a compatibility layer that mimics 1990s browsers. It changes a handful of behaviours — most notably the box model for some elements (e.g. box-sizing on form controls and table cells), how line heights are computed for inline content, and whether font/size properties inherit into tables — so the same CSS can render slightly differently than in standards mode.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>My page</title>
  </head>
  <body>
    Hi
  </body>
</html>

Three things to never skip

  1. `<!doctype html>` — must be the very first line. Lowercase or uppercase, browsers accept both.
  2. `<html lang="en">` — screen readers use this to pick the right voice. SEO uses it to pick the right index.
  3. `<meta charset="utf-8" />` — must be in the first 1024 bytes of the document. Without it, accented characters can render as mojibake. UTF-8 is the only correct answer in 2026.

The 30-second rule

If your page boots in quirks mode, layout can differ from what the CSS specs (and your reset library) promise in subtle ways. Start every new page with the doctype. Always.

Живой просмотр
← К трекуСледующий урок →

Получай один совет по Python или веб-разработке — каждый день в почте

Коротко, без воды, без спама. Отписаться — в один клик.