The <center> tag in HTML is used to set the align of text into center. This tag is not supported in HTML5. CSS property is used to set the align of element instead of center tag in HTML5.
Syntax:
<center> Contents... <center>
Example 1:
<!DOCTYPE html> < html > < head > < title >center tag</ title > < style > h1 { color:green; } </ style > </ head > < body > < center > < h1 >GeeksforGeeks</ h1 > < h2 >< center > Tag</ h2 > < p >GeeksforGeeks: A computer science portal for geeks</ p > </ center > </ body > </ html > |
Output:
Example 2: Use CSS property in HTML5 to set the text alignment into center.
<!DOCTYPE html> < html > < head > < title >CSS center property</ title > < style > body { text-align:center; } h1 { color:green; } </ style > </ head > < body > < h1 >GeeksforGeeks</ h1 > < h2 >CSS center property</ h2 > </ body > </ html > |
Output:
Supported Browser: The browser supported by <center> tag are listed below:
- Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
This article is attributed to GeeksforGeeks.org
0
0
leave a comment
0 Comments