HTML Element <center> Example
The HTML element <center>
is used to center align the contents enclosed within the element.
This element is not supported in HTML5 and you should avoid using it in the markup. Instead, use CSS properties.
Here is an example that explains the element in action. Click the below link to see the live demo.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element center</title>
</head>
<body>
<!-- The center element is obsolete and not valid in HTML5, so avoid using it in your markup -->
<center><p>This paragraph is center aligned using an element.</p></center>
<!-- Alternative and better way to align the content is using CSS properties as shown below. -->
<p style="text-align: center;">This paragraph is also center aligned but using CSS properties.</p>
</body>
</html>
Related Links
- HTML Elements
- HTML Attributes
- HTML Text Formatting
- CSS Alignment