<a href="index.shtml">Home</a>
<p id="dt"></p>
<script>
document.getElementById("dt").innerHTML = "hello";
</script>
I just need both statements on the same line. This must be simple!! (but I cant do it!) Thanks
CodePudding user response:
p
is representing a paragraph and therefore is (usually) a block element. For what you are doing, you would be better served with using an inline element like span
.
Making the element inline will lead to both being displayed on the same line. If switching the tag is not an option, use css to set display:inline
on the paragraph.
CodePudding user response:
The <p>
tag will create a new line by default. One way to prevent this is CSS display: inline
.
<style>
#dt {display: inline;}
</style>
<a href="index.shtml">Home</a>
<p id="dt"></p>
<script>
document.getElementById("dt").innerHTML = "hello";
</script>
CodePudding user response:
<a href="index.shtml" style=' white-space: nowrap;'>Home</a>
<div id="dt" style='display: inline-block;'></div>
<script >
document.getElementById("dt").innerHTML = "hello";
</script>