Attribute (markup language)

from Wikipedia, the free encyclopedia

An attribute is a language element in markup languages ( SGML , XML , XHTML , HTML ). Attributes describe additional properties of an element .

description

Attributes are properties that are assigned to an element . 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"/>

Attribute name

An attribute name must follow the applicable rules for a name in the respective markup language.

XML name

The syntax is described in rule [5] of the XML standard.

The first character, the start character, must be one of the following characters:

":" | [A-Z] | "_" | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]

All other characters must be a start character or one of the following characters:

"-" | "." | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]

SGML name

The syntax is described in rule [55] of the SGML standard.

The first character must be one of the following:

[a-z] | [A-Z]

All other characters must be one of the following characters:

[a-z] | [A-Z] | [0-9] | "-"

Attribute value

If an attribute value is enclosed in double quotation marks "...", all characters except <and are "allowed in the attribute value .

If an attribute value is enclosed in single quotation marks '...', all characters except <and are 'allowed in the attribute value .

There is also another form, for example in HTML ; the Boolean attributes. There are the following options:

  • No value assignment, just the name of the attribute
  • The name of the attribute is assigned as a value.

This means “true” in each case, while “false” can only be caused by completely omitting the attribute name.

<video controls>

particularities

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.

Individual evidence

  1. Name. In: Extensible Markup Language (XML) 1.0 (Fifth Edition). W3C, accessed January 16, 2017 .
  2. ISO 8879: 1986-10. In: din.de. Retrieved December 4, 2016 .
  3. HTML5, as of 2011, accessed on December 22, 2019