Home Web Front-end Front-end Q&A what is html dtd

what is html dtd

Dec 03, 2021 pm 05:45 PM
dtd html

In HTML, DTD refers to "Document Type Definition", which is a set of grammatical rules about tags, a verification mechanism for HTML files, and is part of the composition of HTML files. DTD can define legal XML document building blocks, which uses a series of legal elements to define the structure of the document.

what is html dtd

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

Document Type Definition (DTD) is a set of syntax rules for tags. It is part of the XML1.0 version specification, is the verification mechanism of html files, and is part of the composition of html files.

DTD can define legal XML document building blocks. It uses a series of legal elements to define the structure of the document.

DTD can be declared in an XML document as a line or as an external reference.

Internal DOCTYPE declaration

If the DTD is included in your XML source file, it should be wrapped in a DOCTYPE declaration using the following syntax:

<!DOCTYPE root-element [element-declarations]>
Copy after login

Example of XML document with DTD (please open in IE5 and higher, and choose to view source code):

<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don&#39;t forget me this weekend</body>
</note>
Copy after login

Open this XML file in your browser, and choose " View source code" command.

The above DTD is explained as follows:

  • !DOCTYPE note (second line) defines this document as a note type document.

  • !ELEMENT note (third line) defines the note element as having four elements: "to, from, heading,, body"

  • !ELEMENT to (the fourth line) defines the to element as "#PCDATA" type

  • !ELEMENT from (the fifth line) defines the from element as "#PCDATA" type

  • !ELEMENT heading (line 6) defines the heading element as "#PCDATA" type

  • !ELEMENT body (line 7) defines the body element as "# PCDATA" type

External Document Declaration

If the DTD is located outside the XML source file, then it should be encapsulated in a DOCTYPE definition:

<!DOCTYPE root-element SYSTEM "filename">
Copy after login

This XML document is the same as the above XML document, but has an external DTD: (Click to open the file and select the "View Source Code" command.)

<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don&#39;t forget me this weekend!</body>
</note>
Copy after login

This is the "note.dtd" file containing the DTD:

<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
Copy after login

Why use DTD?

  • With a DTD, each of your XML files can carry a description of its own format.

  • With DTD, independent groups can consistently use a standard DTD to exchange data.

  • Your application can also use a standard DTD to verify data received from the outside.

  • You can also use DTDs to validate your own data.

DTD has three document types: S (Strict), T (Transitional), and F (Frameset).

  • #Strict: Use this type if you need clean markup without clutter in the presentation layer. Please use with Cascading Style Sheets (CSS)

  • Transitional: DTD can contain rendering attributes and elements that the W3C expects to be moved into the style sheet. If your readers are using browsers that do not support Cascading Style Sheets (CSS) and you have to use HTML's rendering features use

  • #Frameset: DTD should be used with Framework documentation. Except that the frameset element replaces the body element, the Frameset DTD is equivalent to the Transitional DTD

html5 basically does not have the strict requirements of XHTML 1.0 Transitional, and has simplified many things and can be used directly <!DOCTYPE HTML>

Recommended tutorial: "html video tutorial"

The above is the detailed content of what is html dtd. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles