英文:
How to join a heading and paragraph in without changing the <h> and <p> tags
问题
我有一个标题,在下面我有一个在<p>标签中的句子。下面给出的是代码。
<!DOCTYPE html>
<html>
<body>
<h1>The p element</h1>
<p>This is a paragraph.</p>
</body>
</html>
上面的代码给出了以下结果:
The p element
This is a paragraph.
我的期望结果是:
The p element This is a paragraph.
我也不想改变<h>
和<p>
标签。
英文:
i have a header and a below that i have sentence in a <p> tag. The below given is the code.
<!DOCTYPE html>
<html>
<body>
<h1>The p element</h1>
<p>This is a paragraph.</p>
</body>
</html>
The above code gives gives me the below result:
The p element
This is a paragraph.
My expected result is:
The p element This is a paragraph.
i also don't want to change the <h>
and <p>
tags
答案1
得分: 2
尝试应用 display: inline
属性。
编辑
您可以将其应用于两个元素:
<h1 style="display:inline">The p element</h1>
<p style="display:inline">This is a paragraph.</p>
或者,使用CSS:
p, h1 {
display: inline;
}
英文:
Try applying the display: inline
property.
EDIT
You would apply it to both elements:
<h1 style="display:inline">The p element</h1>
<p style="display:inline">This is a paragraph.</p>
Or, using CSS:
p, h1 {
display: inline;
}
答案2
得分: 1
Adding CSS would do the magic. Here is an example:
<!DOCTYPE html>
<html>
<style>
.headline h1, .headline p {
display: inline;
}
</style>
<body>
<div class="headline">
<h1>The p element</h1>
<p>This is a paragraph.</p>
</div>
</body>
</html>
英文:
Adding CSS would do the magic. Here is an example:
<!DOCTYPE html>
<html>
<style>
.headline h1, .headline p {
display: inline;
}
</style>
<body>
<div class="headline">
<h1>The p element</h1>
<p>This is a paragraph.</p>
</div>
</body>
</html>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论