HTML Element: <figcaption>
[this page | pdf | back links]
The HTML <figcaption> element indicates a
caption for a <figure>
element. It is new in HTML 5. It can be the first or the last child element of
the <figure>
element.
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>
<figure>
<img src="Pictures/Shape1.jpg">
<figcaption>Dodecahedron</figcaption>
</figure>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("FIGURE");
var x1 = document.createElement("IMG"); x1.setAttribute("src","Pictures/Shape1.jpg");
var x2 = document.createElement("FIGCAPTION");
x2.textContent = "Dodecahedron";
// or use var txt = document.createTextNode("Dodecahedron");
// x.appendChild(txt);
x.appendChild(x1);
x.appendChild(x2);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements