Skip to main content
table of contents
HTML
- Basic structure similar to XML:
<>
tags- Attributes
- Entities for special characters.
- Extra whitespace is generally ignored
- Special-purpose: predefined set of tags.
Sample HTML
<html>
<head>
<title>Hello World</title>
</head>
<body>
<p>
Hello world!
</body>
</html>
Two important attributes supported by all element types:
- class: used to group related elements (typically for controlling display attributes with CSS).
- id: provides a unique identifier for element. Very important when implementing dynamic effects (used to locate a particular element.
Irregular:
- Some tags are singletons, such as
<br>, <p>
. - Not all attributes have to have values:
<select name="equipment" multiple>
- Some elements can overlap:
<p><b>xyz</p><p>second</b> third</p>
- Some tags are singletons, such as
Early browsers tried to "do the right thing" even in the face of incorrect HTML:
- Ignore unknown tags
- Carry on even with obvious syntax errors such as missing
<body>
or</html>
- Infer the position of missing close tags
- Guess that some
<
characters are literal, as in "What if x < 0?" - Example, a document with: Hello, world
& Not obvious how to interpret some documents (and browsers differed). * Users came to depend on browser quirks: * HTML documents with bad syntax still display. * Web page designers don't notice the problems, so bogus pages proliferate. * Browsers can't change to reject bad pages: would "break" too much content. * Newer browsers must emulate quirks of the very first Web browsers.
- Being forgiving allows bad habits to develop, which you then have to tolerate forever.
Annotate
Web Technology