Skip to main content
Practice

Difference Between Span and P Tags

The <span> tag and the <p> tag are both used for text within HTML.

The key difference between the two tags lies in their layout behavior. The <p> tag places each block of text on a new line, whereas the <span> tag allows text to be displayed inline on the same line as other tags.

Using the <p> tag will ensure that the text is placed on a new line each time.

However, with the <span> tag, multiple instances of the tag will still display the text inline on the same line.

Example Code for span Tag
<span>Hello</span> <span>World</span>

In the code above, "Hello" and "World" will be displayed on the same line.


In contrast, the <p> tag places the text on a new line.

Example Code for p Tag
<p>Hello</p>
<p>World</p>

In the code above, "Hello" and "World" will be displayed on separate lines.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.