In html, what can we write in the code to bring the content of my web page in the center ?? I have tried to write the code within {center} tag and {/center} but it’s not working. so any other alternatives ??
I tried to bring centre alignment but it didn’t happen.
3
Answers
Though it’s technically still part of HTML, the
<center>
tag was deprecated in HTML 4.01 to emphasize that CSS stylesheets are the new home for all style and formatting parameters. That was back in 1999.These days, you should create a selector in CSS, then set the attributes you need for a specific effect.
Very general example:
If you want to center content in webpage only via HTML is by using
center
tag.However it is
deprecated
and is recommend to use CSS instead.Centering content within the
div
.Centering
div
itself and it’s contentThe recommended approach is to use the CSS text-align property. You can apply this property to various HTML elements like ,
, or the entire body element to center its content.
Here is an example:
CSS:
For more complex layouts where you want to center both horizontally and vertically, you can explore using CSS properties like margin: 0 auto; or combining text-align with other positioning properties.