Reputation: 49
<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
Upvotes: 0
Views: 1191
Reputation: 25
<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>
Upvotes: 0
Reputation: 39
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>
Upvotes: 0
Reputation: 80
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.
Upvotes: 2