HTML Element: <span>
[this page | pdf | back links]
The
HTML <span> element indicates a section
in a document. It is usually defined with its own style.
The attributes
it can take are HTML
global attributes and HTML event attributes.
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>
<em><span>spanned text</span></em>
<br><br>Created using JavaScript:<br>
<em id="element"></em>
<script>
var x = document.createElement("SPAN");
x.textContent = "spanned text";
// or use var txt = document.createTextNode("spanned text");
// x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements