Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

the paragraph seems it's not a part of the parent

I am a junior in css
I have a footer and 2 paragraph in it
but when I Give border to the footer

footer {
 border: 2px solid red;
    text-align: center;
    height: 50px;
}
    <footer>
      <p>
        واخر دعوانا ان الحمد لله رب العالمين
        <a href=""> اللهم احسن خاتمتنا </a>
      </p>

      <p>اللهم انى اسألك حسن الخاتمة</p>
    </footer>

only the first paragraph is bordered
the second paragraph not bordered as like it’s not a part of the footer

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You’ve given the <footer> an explicit height of 50px, but the text within it exceeds that height. So you’re seeing it overflow from the container.

You can remove the height:

footer {
  border: 2px solid red;
  text-align: center;
}
<footer>
  <p>
    واخر دعوانا ان الحمد لله رب العالمين
    <a href=""> اللهم احسن خاتمتنا </a>
  </p>
  <p>اللهم انى اسألك حسن الخاتمة</p>
</footer>

Or, I suppose depending on what you want to do, other options include handling the overflow differently. For example, if for some reason it must be 50px in height and you want the user to scroll to see the rest of the content:

footer {
  border: 2px solid red;
  text-align: center;
  height: 50px;
  overflow-y: scroll;
}
<footer>
  <p>
    واخر دعوانا ان الحمد لله رب العالمين
    <a href=""> اللهم احسن خاتمتنا </a>
  </p>
  <p>اللهم انى اسألك حسن الخاتمة</p>
</footer>

Other options include modifying the <p> styles within the <footer> to reduce the whitespace so that it fits within the intended height, etc. How you want to style it is up to you, but the original problem was simply that the contents didn’t fit the container.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading