XML — Attributes Reference
Basic Attributes
<element attribute="value"/>
Attribute Types
| Type | Description |
|---|---|
| CDATA | Character data |
| ID | Unique identifier |
| IDREF | Reference to ID |
| NMTOKEN | Name token |
| Enumeration | List of values |
Attribute Defaults
| Default | Description |
|---|---|
| #REQUIRED | Must be present |
| #IMPLIED | Optional |
| #FIXED | Always this value |
| "default" | Default value |
Common Attributes
| Attribute | Elements | Description |
|---|---|---|
| id | Any | Unique identifier |
| class | HTML | CSS class |
| style | HTML | Inline CSS |
| href | a, link | URL |
| src | img, script | Source URL |
| type | input, script | Type |
| name | form, input | Name |
Namespace Attributes
<element xmlns:prefix="URI" xml:lang="en"/>
XML Special Attributes
| Attribute | Description |
|---|---|
| xml:lang | Language |
| xml:space | Whitespace handling |
| xmlns | Namespace declaration |
| xsi:type | Schema type |
Mini Practice
- Add standard attributes
- Use different attribute types
- Set attribute defaults
- Use namespace attributes
Up Next
Continue with Schema Reference — XSD type reference.
Related Topics
Frequently Asked Questions about Attributes Reference
What is Attributes Reference in XML?
Attributes Reference is a fundamental concept in XML. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Attributes Reference?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Attributes Reference.
Why is Attributes Reference important in XML?
Attributes Reference is essential for XML development. Understanding this concept will help you write better code and solve real-world problems more effectively.