Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Angular: Page overflows when height of both html and body is set to 100%

I'm developing a SPA using Angular, and I have specified html, body { height: 100% } and body { margin: 0 } in CSS. In this situation, if I use HTML tags with default margins in a component, such as <h1> tag, the page will overflow.

This seems to be due to the fact that the margin of the first element of body is replaced by the margin of the body, which is different from the behavior in plain HTML. In plain HTML, the top margin of the first element is ignored, and the body never has a margin. However, this behavior is not the case in Angular (or React, to be precise).

What is the cause of this?
Also, is there any way to achieve the normal HTML behavior in Angular?

Samples in Stack Blitz are as follows:

  • Plain HTML: https://stackblitz.com/edit/web-platform-x6cd4l?file=index.html
  • Angular: https://stackblitz.com/edit/angular-ivy-2yrmkw?file=src/app/app.component.ts
  • React: https://stackblitz.com/edit/react-ts-4mdnyl?file=index.tsx

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looks like it's your HTML version is missing <!DOCTYPE html>, so it's being rendered differently. And the overflow is caused by the H1 having a top margin, causing a margin between the body and html.

Once you've added the doctype you can then set margin-top: 0 for h1 and the problem should no longer exist.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!