/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: align

[this page | pdf | back links]

The HTML align attribute indicates the alignment of the element versus surrounding elements. It is not supported in HTML 5 (instead use CSS, e.g. <div style="text-align:center"> … </div>).

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>p {border: 1px solid black; width:200px}</style></head>
<body>
Set using HTML:<br>
<p align="center">Text</p><br>

Set using JavaScript:<br>
<p id="x1">Text</p><br>

<script>
var att = document.createAttribute("align");
att.value = "center";
document.getElementById("x1").setAttributeNode(att);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile