+ 1

Why the second text is not aligned to the center

<html> <head> <title>Attributes</title> </head> <body> <p align="center">This is a text <br /> <hr width="10%" align="right" /> This is also a text. </p> </body> </html>

14th Jul 2017, 10:04 AM
Selina Miraz
Selina Miraz - avatar
5 Antworten
+ 9
Because anyway, the <hr> element is not an valid content for a <p> tag ^^ (semantically non sense) So browsers will try to correct it mostly by dividing the <p> element in two, the second loosing inlined attributes among which 'style' delaration :P You should write a structure like: <p style="/* whatever you want */">text content</p> <hr> <p style="/* whatever else you want */">text content</p> And fir aligning/sizing your <hr> element, you would be adviced to use css and container parent (could be the root <body> element): <div style="text-align:right;"> <p style="text-align:center;">text content</p> <hr style="width:50%;"> <p style="text-align:center;">text content</p> </div> Obviously, it's best practice to externalize css declaration (but here is for explain purpose ;))
14th Jul 2017, 10:49 AM
visph
visph - avatar
+ 15
Try this: <html> <head> <title>Attributes</title> </head> <body> <p align="center">This is a text <br /></p> <hr width="10%" align="right" /><br><p align=center> This is also a text. </p> </body> </html>
14th Jul 2017, 10:08 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
because it is mentioned align=right in hr tag. the property from the innermost element takes priority
14th Jul 2017, 10:07 AM
Gurpreet Singh
Gurpreet Singh - avatar
0
so the next text should have aligned right but it's in the left side. @Gurpreet
14th Jul 2017, 10:09 AM
Selina Miraz
Selina Miraz - avatar
0
This is the code from the HTML Basics Attributes lesson, and this is how the code is presented. Correct syntax needs to be updated with this code.
17th Sep 2017, 5:18 AM
GUARDIAN KAYSA (Yanta)
GUARDIAN KAYSA (Yanta) - avatar