Skip to content
Advertisement

How can I place two statements on same line?

<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

Advertisement

Answer

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.

Advertisement