I have a big question, I am starting with HTML and I saw that to center a title I can use
<h1 style="text-aline: center;"></h1>
and I can also use
<h1 align ="center"></h1>
which method is more recommended and what is the difference between these
I am learning and I want to start with good foundations
3
Answers
The best practice for centering a title is to do it in CSS (with the style attribute)
You can use the center tag to center the title of using html
example
If you are using inline css that can same work.
Example of inline CSS:
You can learn in depth of html
Resources: w3school
It would be best to use
text-align: center
. Aligning things with HTML attributes is generally not best practice, it’s better to use CSS to align things.I’d also recommend moving your CSS to either a
<style>
tag or a separate CSS file to improve the readability of your HTML markup. For example