+ 2
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? https://code.sololearn.com/WV0l037ibKxo/?ref=app
4 ответов
+ 2
If this solves your query.
https://code.sololearn.com/W1gpl0IbwwGG/?ref=app
Hope this helps☺️☺️.
+ 11
I go along with Janning's response
+ 1
There is no need of "body" on CSS. Remove the body and the {}, maintain only the ones from h1.
+ 1
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.