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

326
Views
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 answers
Answer question

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 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!