I am working on an HTML project where I have a JavaScript file that reads from a text file. Currently, the text from the file is displaying in my HTML file, but I would like to style it using CSS. Can anyone provide guidance on how to achieve this? I am still learning and would appreciate simple explanations.
I'm not sure where to begin with this task.
Here is the snippet of HTML code:
<html>
<head>
<meta http-equiv="refresh" content="5">
<script src="overlay.js"></script>
</head>
<body>
</body>
</html>
And here is the JavaScript code (note that 'filename' represents the name of my text file):
new XMLHttpRequest();
var xhr = new XMLHttpRequest;
xhr.open('GET', 'filename', false);
xhr.onload = function () {
document.write(xhr.responseText);
};
xhr.send(null);