# JavaScript HTML DOM Document

« Previous
Next Chapter »

With the HTML DOM, the document object is your web page.

## The HTML DOM Document

In the HTML DOM object model, the document object represents your web page.

The document object is the owner of all other objects in your web page.

If you want to access objects in an HTML page, you always start with accessing the document object.

Below are some examples of how you can use the document object to access and manipulate HTML.

The next chapters demonstrate the methods.

## Finding HTML Elements

Method | Description
--- | ---
document.getElementById() | Find an element by element id
document.getElementsByTagName() | Find elements by tag name
document.getElementsByClassName() | Find elements by class name

## Changing HTML Elements

Method | Description
--- | ---
element.innerHTML= | Change the inner HTML of an element
element.attribute= | Change the attribute of an HTML element
element.setAttribute(attribute,value) | Change the attribute of an HTML element
element.style.property= | Change the style of an HTML element

## Adding and Deleting Elements

Method | Description
--- | ---
document.createElement() | Create an HTML element
document.removeChild() | Remove an HTML element
document.appendChild() | Add an HTML element
document.replaceChild() | Replace an HTML element
document.write(text) | Write into the HTML output stream

## Adding Events Handlers

Method | Description
--- | ---
document.getElementById(id).onclick=function(){code} | Adding event handler code to an onclick event

## Finding HTML Objects

The first HTML DOM Level 1 (1998), defined 11 HTML objects, object collections, and properties. These are still valid in HTML5.

Later, in HTML DOM Level 3, more objects, collections, and properties were added.

Property | Description | DOM
--- | --- | ---
document.anchors | Returns all <a> elements that have a name attribute | 1
document.applets | Returns all <applet> elements (Deprecated in HTML5) | 1
document.baseURI | Returns the absolute base URI of the document | 3
document.body | Returns the <body> element | 1
document.cookie | Returns the document's cookie | 1
document.doctype | Returns the document's doctype | 3
document.documentElement | Returns the <html> element | 3
document.documentMode | Returns the mode used by the browser | 3
document.documentURI | Returns the URI of the document | 3
document.domain | Returns the domain name of the document server | 1
document.domConfig | Obsolete. Returns the DOM configuration | 3
document.embeds | Returns all <embed> elements | 3
document.forms | Returns all <form> elements | 1
document.head | Returns the <head> element | 3
document.images | Returns all <img> elements | 1
document.implementation | Returns the DOM implementation | 3
document.inputEncoding | Returns the document's encoding (character set) | 3
document.lastModified | Returns the date and time the document was updated | 3
document.links | Returns all <area> and <a> elements that have a href attribute | 1
document.readyState | Returns the (loading) status of the document | 3
document.referrer | Returns the URI of the referrer (the linking document) | 1
document.scripts | Returns all <script> elements | 3
document.strictErrorChecking | Returns if error checking is enforced | 3
document.title | Returns the <title> element | 1
document.URL | Returns the complete URL of the document | 1

« Previous
Next Chapter »

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples