如何防止DIV标签开始新行? [英] How do I prevent DIV tag starting a new line?

查看:100
本文介绍了如何防止DIV标签开始新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向包含标签的浏览器输出一行文本。当它被渲染时,看起来DIV会导致一个新行。如何在同一行中包含div标签中的内容 - 这里是我的代码。

 <?php 
echo(< a href = \pagea.php?id = $ id \> Page A< / a>)
?>
< div id =contentInfo_new>
< script type =text / javascriptsrc =getData.php?id =<?php echo($ id);?>>< / script>
< / div>

我试图在这里整理它。如何在单行上显示此显示?

解决方案

div 标记是块元素,导致该行为。



您应该使用 span 元素,而不是< 。



如果您真的要使用 div ,请添加 style =display:inline。 (你也可以把它放在一个CSS规则中)


I want to output a single line of text to the browser that contains a tag. When this is rendered it appears that the DIV causes a new line. How can I include the content in the div tag on the same line - here is my code.

<?php 
  echo("<a href=\"pagea.php?id=$id\">Page A</a>") 
?>
<div id="contentInfo_new">
  <script type="text/javascript" src="getData.php?id=<?php echo($id); ?>"></script>
</div>

I have tried to tidy it up here. How can I have this display on a single line?

解决方案

The div tag is a block element, causing that behavior.

You should use a span element instead, which is inline.

If you really want to use div, add style="display: inline". (You can also put that in a CSS rule)

这篇关于如何防止DIV标签开始新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆