CodesJava

Easy learning with example program codes

Center HTML

HTML <center> Tag

The HTML <center> tag is not supported in HTML5. It is a block-level element, and thus both block-level and inline contents are included within it. It displays the content in the middle of the page. After being deprecated in HTML 4, it has been obsolete in HTML5. The CSS property text-align: center; can be used instead of it.

Syntax:

<center>Content</center>

Example:

<!DOCTYPE html>
<html>
<body>
<p>Hello World!!</p>
<center>Hello World!! I am center-aligned.</center>
<p>Hello World!!</p>
</body>
</html>

Output:

Explanation:

In the above example, we are using the HTML <center> tag to display the specified content at the center of the web page.

 

Example: Using CSS.

<!DOCTYPE html>
<html>
<head>
<style >  
h3{  
text-align: center;}  
</style>
</head>
<body>
<p>Hello World!!</p>
<h3>Hello World!! I am center-aligned.</h3>
<p>Hello World!!</p>
</body>
</html>

Output:

Explanation:

In the above example, we are using the CSS property text-align to display the specified content at the center of the web page.

Tag specific Attributes:

There is no tag specific attribute for the HTML <center> however till it was not removed completely, it used to support the HTML Global Attributes.

Supporting Browsers:

Chrome, IE, Firefox, Opera and Safari.

Please follow and like us:
error
Posted in HTML   









Copyright © 2019 CodesJava DMCA.com Protection Status