Harvard Extension School
CSCI E-12 Fundamentals of Web Site Development | Fall 2019

## HTML/SGML/XML -- What's the Difference?

Main differences between HTML/SGML and XML:

| HTML | XML
--- | --- | ---
1. | End tags can be "implied" Closing elements that have implied end tags `<img src="images/lake.jpg" alt="Lake" >`
    <ul>
        <li>coffee
        <li>tea
    </ul>
| End tags always required (even for "empty" elements) `<img src="images/lake.jpg" alt="Lake" />`
    <ul>
        <li>coffee</li>
        <li>tea</li>
    </ul>
2. | Start tags can be "implied"
    <!DOCTYPE html>
    <head>
    <title>My Document</title>
    <body>
    <h1>My Document</h1>
| Start tags always required
    <!DOCTYPE html>
    <html>
    <head>
    <title>My Document</title>
    </head>
    <body>
    <h1>My Document</h1>
    </body>
    </html>
3. | Element and attribute names are not case-sensitive `<IMG SrC="images/lake.jpg" aLT="Lake" >` | Element and attribute names are case-sensitive `<img src="images/lake.jpg" alt="Lake" />`
4. | Attribute values do not need to be in quotes if the values contain alpha-numeric characters only `<img src=images/lake.jpg alt=Lake >` | Attribute values must always be in quotes `<img src="images/lake.jpg" alt="Lake" />`

### Best Practices for Starting Out

- Use start and end tags, even if optional
- Lower case element and attribute names
- Use quotes around attribute values
- Preference note: David prefers the "XML" syntax, but that's a preference, not a mandate; also it is a preference not shared by everyone.

Copyright © David Heitmeyer