HTML Element: <figure>
[this page | pdf | back links]
The
HTML <figure> element indicates a
piece of self-contained content, like an illustration, diagram or piece of
computer code. It is new in HTML 5. Ideally, the content of a <figure> element should not
specifically link to its exact position within the text (e.g. in a research
paper figures will be referred to in the text, but can be positioned in a
variety of places without altering the meaning of the text). A <figcaption>
element is used to add a caption to a <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