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

328
Vistas
How to do a line break in HTML with external Javascript file?

Making a website for my Javascript class which tells the user information about their browser and such. I have the technical part down, but line breaks aren't working for some reason and it's making formatting a headache. For example, here is a function that pretty much tells the user's screen resolution and puts it into the empty output div in the HTML

function screenResolution() {
    clearBox();
    document.getElementById('heading').textContent = "Screen Resolution";
    document.getElementById('output').textContent = "Width: " + screen.width + "Height: " + screen.height;
}

I'm wanting to put a line break inbetween Width: xyz and Height: xyz so it looks like

Width: 1920

Height: 1080

but using \n or <br> both don't seem to be working. It'll just put the tags in like they're strings so it'll look like

Width: 1920<\br>Height:1080

Any help?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should be able to use innerHTML property instead of textContent:

document.getElementById('output').innerHTML = "Width: " + screen.width + "<br>Height: " + screen.height;

This is assuming that output is not a text field or textare (i.e. div, td, etc)

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