Align Horizantally CSS | Sololearn: Learn to code for FREE!


Align Horizantally CSS

I'm trying to align my h1 and paragraph on HTML to the center using CSS. I've read the CSS lesson on it and I'm 90% sure I've typed everything In correctly, but it's still not aligning correctly. Can anybody tell me why?

9/6/2018 2:42:50 AM

Sir White Cat

4 Answers

New Answer


If this solves your query. Hope this helps☺️☺️.


I go along with Janning's response


There is no need of "body" on CSS. Remove the body and the {}, maintain only the ones from h1.


Your CSS has: h1 {text-align:center;} #Intro {text-align:center;} But #Intro isn't being called/used anywhere by the HTML. (You would want to put id="Intro" in the opening tag of whatever you wanted to apply it to, keeping in mind that you can only use an id once in an HTML file because ids must be unique.) Instead, if you wanted centering to apply to all paragraphs, I would recommend: h1, p {text-align:center;} so that all first level headings and all paragraphs will have centered text. This means article elements will not have centered text.