Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda