HTML Element: <legend>
[this page | pdf | back links]
The HTML <legend> element indicates a
caption for a <fieldset>
element.
The attributes
it can take are HTML
global attributes and HTML event attributes.
It used to accept 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. It also supports the following additional
properties:
Property
|
Description
|
More
|
form
|
Returns form that contains
element
|
Here
|
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>
<fieldset>
<legend>Description</legend>
Fieldset contents
</fieldset>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("FIELDSET");
var y = document.createElement("LEGEND");
y.textContent = "Description"
var txt = document.createTextNode("Fieldset contents");
x.appendChild(y);
x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements