0

horizontal alignment css

when playing around with the code under horizontal align, i wanted to see what happen when i removed the align code from html, but kept it is CSS. the align code isnt working in css. html <p>This paragraph is aligned to <strong>left.</strong></p> <p> This paragraph is aligned to <strong>right.</strong></p> <p>This paragraph is aligned to <strong>center.</strong></p> css p.left { text-align: left; } p.right { text-align: right; } p.center { text-align: center; }

7th Apr 2017, 4:34 PM
Melissa Harris
Melissa Harris - avatar
4 Réponses
+ 9
https://code.sololearn.com/WznGJxWinj6g/?ref=app when you write "p.right" in css this means you are selecting all the paragraphs defined in class "right" for styling. in your code you wrote "right" in strong tag, refer above listed example. <html> <head> <style> p.left{ text-align: left; } p.right{ text-align: right; } p.center{ text-align: center; } </style> </head> <body> <p class="left">This paragraph is aligned to <strong>left</strong></p> <p class="right" > This paragraph is aligned to <strong>right</strong></p> <p class="center">This paragraph is aligned to <strong>center</strong></p> </html>
7th Apr 2017, 5:04 PM
Hardik Raut
Hardik Raut - avatar
+ 4
<p class="left">This paragraph is aligned to <strong>left.</strong></p> You have to give class attribute to every p tag because you are setting styles based on class. p.something => applies styles to all P tags that has class something. You need to modify your code accordingly.
7th Apr 2017, 4:50 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 1
To apply the style called "center" to the paragraph you have to specify the class. p.center means apply the class style called "center" to this paragraph to apply it you have call the class by using: <p class="center"> your text </p>
7th Apr 2017, 4:55 PM
Dina Dinarax
Dina Dinarax - avatar
0
i understand now. i had to change the class to another word to understand
7th Apr 2017, 5:30 PM
Melissa Harris
Melissa Harris - avatar