HTML Element: <var>
[this page | pdf | back links]
The HTML <var> element is a phrase element
indicating a variable in computer code. It is not depreciated, but typically a
richer effect can be achieved using CSS.
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>
<var>text representing a computer variable</var>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("VAR");
x.textContent = "text representing a computer variable";
// or use var txt = document.createTextNode("text representing a computer variable");
// x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements