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?
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)