HTML Element: <div>
[this page | pdf | back links]
The HTML <div> element indicates a
section (i.e. division) in a document. It is usually assigned its own style,
differentiating it from other elements next to it in the document.
The attributes
it can take are HTML
global attributes and HTML event attributes.
It used to support the align
attribute but this is no longer supported in HTML 5.
To create or access such
an element in JavaScript
see here. The
corresponding HTML DOM
object supports standard
DOM properties and methods. The default style applicable to this element is
shown here.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<div>a div element</div>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("DIV");
x.textContent = "a div element";
// or use var txt = document.createTextNode("a div element");
// x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements