0
<!DOCTYPE html>
<html>
  <head>
    <title>my web page</title>
    <meta name="author" content="akhil">
    <style>
      h1{color: red;font-size: 400%}
      p{color: red}
    </style>
  </head>
  <body>
    <section>
      <h1>hello how are you?</h1>
      <p>i am fine.<hr> what about you?</p>
    </section>
  </body>
</html>

In this document style is applying to h1 and p but it is not applying to line after hr tag, how to make style apply to line after hr tag?

1

2 Answers 2

1

A paragraph cannot contain a <hr /> tag, so all text after <hr /> will be out of <p> tag. It's better to use this way:

h1 {
  color: red;
  font-size: 400%;
}
p {
  color: red;
}
<section>
  <h1>hello how are you?</h1>
  <p>i am fine.</p>
  <hr />
  <p>what about you?</p>
</section>

This is how the browsers render your code:

enter image description here

Your content isn't inside the <p /> tag anymore.

14
  • but still what about you is not coloured,how to make what about you line coloured? Jul 7, 2016 at 12:35
  • @AkhilSharma I can see it is red in colour. Jul 7, 2016 at 12:35
  • <p>i am fine.</p> <hr /><p>what about you?</p> this is what i tried and now it is in colour<thanks praveen Jul 7, 2016 at 12:38
  • i have another query ,why you written <hr /> and not simple <hr>? Jul 7, 2016 at 13:02
  • @AkhilSharma <hr /> is a self-closing tag. Personal preference, I use XHTML. :) You can use anything. Jul 7, 2016 at 13:03
0

you can close and open the paragraf:

<p>i am fine.</p> <hr><p> what about you?</p>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.