Definition and Usage
The body element defines the documents′ body. It contains all the contents of the document (like text, images, colors, graphics, etc.).
Differences Between HTML and XHTML
All "presentation attributes" of the body element were deprecated in HTML 4.01.
All "presentation attributes" of the body element are not supported in XHTML 1.0 Strict DTD.
Example
| <html> <head> </head> <body> </html> 数据挖掘研究院 |
Optional Attributes
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
| Attribute | Value | Description | DTD |
|---|---|---|---|
| alink | rgb(x,x,x) #xxxxxx colorname |
Specifies the color of the active links in the document. Deprecated. Use styles instead. | TF |
| background | file_name | An image to use as the background. Deprecated. Use styles instead. | TF |
| bgcolor | rgb(x,x,x) #xxxxxx colorname |
The background color of the document. Deprecated. Use styles instead. | TF |
| link | rgb(x,x,x) 数据挖掘研究院 #xxxxxx colorname |
Specifies the color of all the links in the document. Deprecated. Use styles instead. | TF |
| text | rgb(x,x,x) #xxxxxx colorname |
Specifies the color of the text in the document. Deprecated. Use styles instead. | TF |
| vlink | rgb(x,x,x) #xxxxxx colorname |
Specifies the color of the visited links in the document. Deprecated. Use styles instead. | TF |
Standard Attributes
| id, class, title, style, dir, lang, xml:lang |
HTML tags can have attributes. The special attributes for each tag are listed under each tag description. The attributes listed here are the core and language attributes that are standard for all tags (with a few exceptions). 数据挖掘研究院
Core Attributes
Not valid in base, head, html, meta, param, script, style, and title elements. 数据挖掘研究院
| Attribute | Value | Description |
|---|---|---|
| class | class_rule or style_rule | The class of the element |
| id | id_name | A unique id for the element |
| style | style_definition | An inline style definition |
| title | tooltip_text | A text to display in a tool tip |
Language Attributes
Not valid in base, br, frame, frameset, hr, iframe, param, and script elements. 数据挖掘研究院
| Attribute | Value | Description |
|---|---|---|
| dir | ltr | rtl | Sets the text direction |
| lang | language_code | Sets the language code |
Keyboard Attributes
| Attribute | Value | Description |
|---|---|---|
| accesskey | character | Sets a keyboard shortcut to access an element |
| tabindex | number | Sets the tab order of an element |
Window Events
Only valid in body and frameset elements
| Attribute | Value | Description |
|---|---|---|
| onload | script | Script to be run when a document loads |
| onunload | script | Script to be run when a document unloads |
Form Element Events
Only valid in form elements. 数据挖掘实验室
| Attribute | Value | Description |
|---|---|---|
| onchange | script | Script to be run when the element changes |
| onsubmit | script | Script to be run when the form is submitted |
| onreset | script | Script to be run when the form is reset |
| onselect | script | Script to be run when the element is selected |
| onblur | script | Script to be run when the element loses focus |
| onfocus | script | Script to be run when the element gets focus |
Keyboard Events
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.
| Attribute | Value | Description |
|---|---|---|
| onkeydown | script | What to do when key is pressed |
| onkeypress | script | What to do when key is pressed and released |
| onkeyup | script | What to do when key is released |
Mouse Events
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.
| Attribute | Value | Description |
|---|---|---|
| onclick | script | What to do on a mouse click |
| ondblclick | script | What to do on a mouse doubleclick |
| onmousedown | script | What to do when mouse button is pressed |
| onmousemove | script | What to do when mouse pointer moves |
| onmouseover | script | What to do when mouse pointer moves over an element |
| onmouseout | script | What to do when mouse pointer moves out of an element |
| onmouseup | script | What to do when mouse button is released |

