в вместо . Ни один браузер в мире не будет иметь проблем с этим! Однако валидатор жалуется, что вы не должны этого делать. (Тем не менее, вы действительно не должны этого делать, но вы понимаете, что я имею в виду. Для совместимости браузеров тестирование во многих различных браузерах более важно, чем проверка того, что ваш источник прошел валидатор.)

HTML Declaration

The declaration is the first line of the code in HTML or XHTML document. It specifies the HTML version used in the document. Each HTML document should start with this declaration: so the browsers will render the page compliant with HTML standards. In HTML 4.01, this declaration refers to a Document Type Definition (DTD), which specifies the structure and the legal elements of an XML document.

Syntax

[Root element] [Publicity] "[Registration]//[Organization]//[Type] [Name]//[Language]" "[URL]">

Parameters

Root element — a parent element that contains all the other elements. For HTML it is the tag.

Publicity — the document can be PUBLIC or SYSTEM (local files, for example). For HTML/XHTML the value is PUBLIC.

Registration — can have two values: plus (+) — the developer is registered in ISO (International Organization for Standardization) and — (minus) — the developer is not registered. For W3C, the value is set to «-«.

Organization — the name of DTD developer. The developer of HTML/XHTML is W3C, and its name is declared in .

Type — the type of the document. For HTML/XHTML the value is DTD.

Name — unique identifier describing DTD.

Language — the language of the document (two letters in uppercase). For HTML/XHTML the language is English (EN).

Читайте также:  Html style div height auto

URL — the URL of the document type description (e.g. https://www.w3.org/TR/html4/loose.dtd).

Types of the Declaration for HTML

There are three types of the declaration for HTML:

Strict — contains all HTML elements and attributes. However, the presentational or deprecated elements are not included.

HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd">

Transitional — contains all HTML elements and attributes, including presentational and deprecated elements. Frames are not allowed.

HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">

Frameset — is equal to Transitional, but allows the use of frames.

HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "https://www.w3.org/TR/html4/frameset.dtd">

There is only one version of declaration for HTML 5.

Example of the HTML declaration:

html> html> head> title>Title of the document title> head> body> h2>Elements example h2> p>This is some paragraph. p> p>This is another paragraph br/> with line break. p> body> html>

Result

paragraph

Types of the Declaration for XHTML

Here you can find types of the declaration for XHTML.

XHTML 1.0 Strict

This DTD includes all the HTML elements and attributes, except presentational or deprecated elements. This DTD doesn’t allow frameworks.

html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

This DTD includes all the HTML elements and attributes, as well as presentational and deprecated elements. Framesets are not allowed.

html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

This DTD is similar to XHTML 1.0 Transitional, but framesets are allowed.

html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

This DTD is equal to XHTML 1.0 Strict, but allows adding modules (e.g., to provide Ruby support for East-Asian languages).

html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Источник

charset = iso-8859-1 с выдает предупреждение?

Я действительно не понимаю, что происходит, также я даже не знаю, как использовать тег DOCTYPE, я только что скопировал и вставил один из Интернета.

Может кто-то указать мне в правильном направлении, чтобы понять:

6 ответов

  • Любая проверка HTML5 должна приниматься с солью. Спектр все еще находится в активной разработке, и не все установлено в камне.
  • Вы используете синтаксис HTML4 для этого метатега. Попробуйте

Тем не менее, HTML-валидаторы не выполняют эту большую цель в этот день и в возрасте.

Кроме того, почему вам нужно указать эту конкретную кодировку?

Мой плохой, по-видимому, по умолчанию для HTML4 был iso = 8869-1. Тем не менее, кодировка по умолчанию для HTML5 — utf-8.

Более подробную информацию о методе HTML5 можно найти в этом сообщении от Джона Резига

Что означает этот комментарий ?: «HTML validators don’t serve that much purpose in this day and age.»

@Madmartigan Большинство браузеров используют другие правила для интерпретации HTML, чем валидатор W3. Например, поместите

Я полностью не согласен: валидатор поймает вещи, которые могут не попасться невооруженным глазом. Неверный HTML — отличный способ получить неожиданное, противоречивое поведение, потому что каждый браузер может обрабатывать его по-своему. Примеры: незакрытые или несоответствующие теги, недействительные или поврежденные атрибуты, кавычки, где их не должно быть, неопределенные строки сущностей, неправильное вложение, пропущенные обязательные атрибуты и т. Д. Я не уверен, что вы делаете с этим примером.

Изменение DOCTYPE — это просто выключение предупреждения — на самом деле это не исправление.

iso-8859-1 и windows-1252 — очень похожие кодировки. Они отличаются только символами, связанными с 32 байтовыми значениями от 0x80 до 0x9F, которые в iso-8859-1 отображаются для управления символами, а в windows-1252 сопоставляются с некоторыми полезными символами, такими как символ евро.

Управляющие символы бесполезны в HTML, и веб-авторы часто ошибочно объявляют iso-8859-1 и все же используют один или несколько из этих 32 значений, как если бы они использовали windows-1252 , поэтому браузеры, когда видят кодировку iso-8859-1 объявленный автоматически изменит это на windows-1252 .

Валидатор просто предупреждает вас, что это произойдет. Если вы не используете ни одно из 32 байтовых значений, вы можете просто игнорировать предупреждение — это НЕ ошибка. Если вы, и вы действительно хотите интерпретировать iso-8859-1 значения байта, а не интерпретацию windows-1252 , вы делаете что-то неправильно.

Опять же, это переключение происходит в браузерах для любого DOCTYPE, это просто, что валидатор HTML5 более полезен в отношении того, что он говорит вам, чем валидатор HTML4.

«Использование windows-1252 вместо объявленной кодировки iso-8859-1». Это означает, что файл был сохранен с окнами 1252 для кодирования при создании (например, Western Windows 1252 или cp1252), и в объявлении charset говорится: «Эй, прочитайте этот файл с iso-8859-1», если это не кодировка файла.

По этой причине существует мета-кодировка. Он существует, чтобы объявить кодировку файла, который вы отправляете/читаете/используете, когда, например, браузер, читает документ, он знает, что кодирует файл.

Подробно вы указали эту кодировку:

Но файл, который вы проверяете, фактически закодирован в Windows 1252. Как? Зачем? Проверьте используемый текстовый редактор и какую кодировку он использует для сохранения файлов. Если редактор может быть настроен на изменение кодировки, выберите тот, который вы хотите использовать.

О HTML5

оба действительны для HTML5. См. < meta charset = "utf-8" → >vs

Источник

charset=iso-8859-1 with throwing a warning?

Changing the DOCTYPE is simply turning off the warning — it isn’t actually fixing anything.

iso-8859-1 and windows-1252 are very similar encodings. They differ only in the characters associated with the 32 byte values from 0x80 to 0x9F, which in iso-8859-1 are mapped to control characters and in windows-1252 are mapped to some useful characters such as the Euro symbol.

The control characters are useless in HTML, and web authors often mistakenly declare iso-8859-1 and yet use one or more of those 32 values as if they were using windows-1252 , so browsers when they see the iso-8859-1 charset being declared will automatically change this to be windows-1252 .

The validator is simply warning you that this will happen. If you’re not using any of the 32 byte values, then you can simply ignore the warning — it’s NOT an error. If you are, and you genuinely want the iso-8859-1 interpretation of the byte values and not the windows-1252 interpretation, you are doing something wrong.

Again, this switching happens in browsers for any DOCTYPE, it’s just that the HTML5 validator is being more helpful about what it is telling you than the HTML4 validator is.

  1. Any HTML5 validation should be taken with a grain of salt. The spec is still under active development, and not everything is set in stone.
  2. You’re using the HTML4 syntax for that meta tag. Try

That said, HTML validators don’t serve that much purpose in this day and age.

Also, why do you need to specify that particular charset?

My bad, apparently the default for HTML4 was iso=8869-1. That said, the default charset for HTML5 is utf-8.

More information about the HTML5 doctype can be found in this post by John Resig

It throws a warning Line 4, Column 72: Using windows-1252 instead of the declared encoding iso-8859-1.

It means the file was saved with the encoding windows 1252 on creation (aka Western Windows 1252 or cp1252) and your charset declaration says «hey read this file with iso-8859-1» when that’s not the encoding the file has.

The meta charset exist for that reason. It exist to declare the encoding of the file you are sending/reading/using so when, for example a browser, reads the document it knows what encoding the file is using.

In detail, you have this charset declared:

But the file you are validating is actually encoded in Windows 1252. How? Why? Check the text editor you are using and what encoding it is using to save files. If the editor can be configured to change the encoding, choose the one you want to use.

Источник

Doctype

Документация по Haml

Когда вы описываете документ HTML с помощью Haml, то вы можете полностью указать тип документа или сгенерировать его автоматически, используя тип документа обёрнутый в . . Например:

. XML . %html %head %title Myspace %body %h1 I am the international space station %p Sign my guestbook 
   Myspace   I am the international space station Sign my guestbook   

Когда метод :format имеет значение :xhtml , то вы можете указать конкретный доктайп после . . Список поддерживаемых доктайпов:

.
XHTML 1.0 Transitional
. Strict
XHTML 1.0 Strict
. Frameset
XHTML 1.0 Frameset
. 5
XHTML 5
. 1.1
XHTML 1.1
. Basic
XHTML Basic 1.1
. Mobile
XHTML Mobile 1.2
. RDFa
XHTML+RDFa 1.0

Когда метод :format имеет значение :html4 , то список поддерживаемых доктайпов такой:

.
HTML 4.01 Transitional
. Strict
HTML 4.01 Strict
. Frameset
HTML 4.01 Frameset

Когда метод :format имеет значение :html5 , то сокращение . всегда имеет значение .

Если вы не используете кодировку UTF-8 для документа, то вы можете указать другую кодировку объявлении доктайпа. Например:

Если mime_type документа будет опознан как text/xml , то формат документа будет :xhtml , не зависимо от того, какой формат задан глобально: :html4 или :html5 .

На сайте функционирует система проверки ошибок. Обнаружив неточность в тексте, выделите ее и нажмите Ctrl + Enter. Также отправить оповещение об ошибке можно, нажав на эту ссылку.

  • Немного о Haml
  • Использование Haml
    • Защита от XSS в Rails
    • Модуль Ruby
    • Настройки Haml
    • Кодировки
    • Экранирование
    • Обозначение элемента
    • Атрибуты
      • Атрибуты :class и :id
      • Атрибуты в стиле HTML
      • Атрибуты в стиле хеша Ruby 1.9
      • Методы генерации атрибут
      • Булевы атрибуты
      • Использование data-атрибут HTML5
      • Неявное указание тега DIV
      • Комментарии HTML
        • Условные комментарии
        • Включение Ruby
        • Запуск Ruby
          • Блоки Ruby
          • :cdata
          • :coffee
          • :css
          • :erb
          • :escaped
          • :javascript
          • :less
          • :markdown
          • :maruku
          • :plain
          • :preserve
          • :ruby
          • :sass
          • :scss
          • :textile
          • Пользовательские фильтры
          • surround
          • precede
          • succeed

          Источник

Оцените статью