Flint_Lockwood
Flint_Lockwood

Reputation: 165

How to join a heading and paragraph in without changing the <h> and <p> tags

i have a header and a below that i have sentence in a

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

Upvotes: 0

Views: 91

Answers (2)

Erick Piller
Erick Piller

Reputation: 33

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;
}

Example

Upvotes: 2

Daniel
Daniel

Reputation: 139

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>  

Upvotes: 1

Related Questions