HTML Centered
To center HTML content and/or elements we just need to enclose them inside a <centre> element.
Example:
<!doctype html><html><head><title>Content Center </title></head><body><center><h1>I am in a centered heading.</h1><p>I am in centered paragraph.</p><img src="imgg.jpg" width="250px"></center></body></html>
Output:
⚠Update! The <center> element is deprecated,it means that browser may not support it anymore in the future.
Alternative:
To center text and images, we can use CSS styling.
The style="text-align: center" attribute can be used as an alternative to the <centre> element.
Example:
<!doctype html><html><head><title> Using CSS Center the Content </title></head><body><div style="text-align: center;"><h1>I am a centered headding using CSS.</h1><p>I am a centered paragraph using CSS.</p><img src="imgg.jpg" width="250px"></div></body></html>
Post a Comment