Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to get the list of document properties which can be accessed using W3C DOM?
The Document Object Model (DOM) provides several key properties that allow you to access and manipulate different parts of an HTML document. These properties are standardized by the W3C and are available across all modern browsers.
Core Document Properties
Here are the essential document properties you can access using the W3C DOM:
| Property | Description & Example |
|---|---|
| body |
A reference to the Element object that represents the <body> tag of the document.
document.body
|
| defaultView |
A read-only property that represents the window in which the document is displayed.
document.defaultView
|
| documentElement |
A read-only reference to the <html> tag (root element) of the document.
document.documentElement
|
| implementation |
A read-only property that represents the DOMImplementation object for this document.
document.implementation
|
Example Usage
Here's how you can access and use these document properties in practice:
<!DOCTYPE html>
<html>
<head>
<title>Document Properties Example</title>
</head>
<body>
<h1>Testing Document Properties</h1>
<script>
// Access the body element
console.log("Body tag name:", document.body.tagName);
// Access the document element (html tag)
console.log("Root element:", document.documentElement.tagName);
// Access the default view (window object)
console.log("Is defaultView same as window?", document.defaultView === window);
// Access implementation details
console.log("Has HTML feature:", document.implementation.hasFeature("HTML", "1.0"));
</script>
</body>
</html>
Body tag name: BODY Root element: HTML Is defaultView same as window? true Has HTML feature: true
Common Use Cases
These properties are frequently used for:
- document.body - Adding content, changing styles, or attaching event listeners to the body
- document.documentElement - Accessing the root HTML element for full-page modifications
- document.defaultView - Cross-frame communication or accessing the global window object
- document.implementation - Feature detection and DOM capability checking
Conclusion
These core document properties provide essential access points to key parts of your HTML document. Understanding these properties is fundamental for effective DOM manipulation and web development.
Advertisements
