Element (markup language)

from Wikipedia, the free encyclopedia

An element is a structural unit ( node ) in an information tree represented by a markup language ( SGML , XML , HTML , XHTML , HTML5 ) . It consists of the element identifier, the element properties ( attributes ) and the element content. Elements are represented by tags.

description

An element is used to mark up text in order to give it a structure. An element is represented by a tag ('label, marking'):

<Bezeichner>Inhalt</Bezeichner>

The element here is which Bezeichneris formed by the start day (opening day) <Bezeichner>and the end day (closing day) </Bezeichner>. The identifier for the start day and end day must be the same. The content is the enclosed text:

<Name>Johann Gottfried Seume</Name>

The content can also contain other elements and texts.

<Name>
    <Vorname>Johann Gottfried</Vorname>
    <Nachname>Seume</Nachname>
</Name>

Empty elements are elements that do not contain any text or other elements.

<Leer></Leer>

In Web- SGML , XML and XHTML , empty elements can be marked with the Empty Element Tag . The syntax of the empty tag corresponds to a start tag which is ended with the character string />.

<Leer/>

In SGML and HTML , an empty element is formed with a start tag. Elements only

  • whose content model is declared in the DTD with EMPTY (empty) or
  • whose end tags are declared in the DTD as end tag minimization or
  • whose elements are allowed as possible empty elements (only HTML version 5)

are allowed as empty elements. The end tag is simply left out:

<Leer>

Additional properties are assigned to an element with attributes . The attributes are specified after the element identifier within the start tag or empty tag.

<Elementname Attributname="Attributwert">

An attribute consists of an assignment Attributname="Attributwert"(property name = property value ). The attribute value is enclosed in double "..."or single '...'quotation marks.

<img src="bild.jpg"/>

Several attributes are listed separated by separators (spaces, tabs , line breaks):

<img src="bild.jpg" title="Abbildung"/>

In XML , XHTML and HTML (version 5), the pairs consisting of assignments of attribute name and attribute value must always be specified in full. The attribute values ​​must always be put in quotation marks.

In SGML and HTML (Version 1 to 4), the complete specification is also always permitted. However, depending on the DTD, simplifications are also possible here.

particularities

SGML

With SGML, the declaration can be used to define how elements should look (they do not necessarily have to be in angle brackets). You can also set the case sensitivity and the presence of start and end days (day minimization). Elements declared as EMPTY must not have an end tag. The representation of the attributes can also be defined with the declaration. Attributes can e.g. B. minimized in such a way that only the value of the attribute is given.

XML

With XML , all opened elements must also be closed again. The upper / lower case is always considered. Attributes must always be specified as a name / value pair.

Empty elements can be />specified in XML with the empty tag, identifier :

<colspec colwidth="10*"/>

HTML (version 1 to 4)

Some HTML elements do not have to be explicitly closed (e.g. <p>). This is because HTML is an application of SGML that enables tag minification, which is set in the Document Type Definition (DTD). Likewise, some attributes can simply be specified by their content.

Empty tags are specified in the following form:

<img src="bild.jpg">

Tag minimization is activated, i. H. not every element has to be closed explicitly:

<p>Das ist der erste Absatz
<p>Das ist der zweite Absatz

XHTML

In XHTML , empty elements are represented in the XML syntax:

<img src="bild.jpg"/>

Tag minimization is not possible, each element must be explicitly closed:

<p>Das ist der erste Absatz</p>
<p>Das ist der zweite Absatz</p>

HTML (version 5)

In HTML5 , empty elements are specified as in SGML and HTML (version 1–4):

<img src="bild.jpg">

For certain elements there is a kind of tag minimization like in SGML. Here for the item <li>shown

<ul>
    <li>Das ist der erste Listeneintrag
    <li>Das ist der zweite Listeneintrag
</ul>

Application example HTML (version 4)

Up to version HTML 4, HTML also uses SGML optimizations that make it possible to display documents in a very simplified manner (e.g. with the SHORTTAG optimization). So is z. For example, the following is a complete standard HTML document ( file ) compared to the complete parse tree (complete structure in the browser ):

HTML document complete parse tree
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>HTML-Beispiel</>
<p/Das ist ein Textabsatz./
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
    <head>
        <title>HTML-Beispiel</title>
    </head>
    <body>
        <p>Das ist ein Textabsatz.</p>
    </body>
</html>

The following additions are implicitly made here:

  • Opening the titleelement opens the htmland headelement.
  • The title element is </ended again by the character string .
  • Opening an element of the body ( body) implicitly opens it and headcloses the header ( ) beforehand .
  • The start tag of the pelement /ends with the first slash ( ). The next slash closes the pelement.
  • The end of the document ends the body and the htmlelement.

See also

Individual evidence

  1. ISO 8879 Technical Corrigendum 2: 1999-11. In: www.din.de. Retrieved November 9, 2016 .
  2. Extensible Markup Language (XML) 1.0 (Fifth Edition). In: www.w3.org. Retrieved December 4, 2016 .