XML DTDLesson 79Free preview
DTD Elements vs Attr
This lesson is part of XML · All levels
Summary
Elements and attributes can store similar information, but there are standard guidelines for selecting them. Attributes are suitable for short, single-text metadata, while long, multi-valued, or structured data should be placed as elements. Attributes are also non-sequential and cannot have children, so they are less flexible for the data that may develop.
Key points
- Attributes can only contain a single text, without children.
- Attributes do not have a sequence between other attributes
- Multi-valued or long-term data is better as an element
- Attributes that fit metadata such as category, gender, orientation
- Selecting elements makes it easier to add data later on
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.