HTML Paragraph

The <p>  element represents a paragraph. Paragraph element is used to publish text on the web pages. Paragraphs are Block-Level elements. HTML Paragraph

Paragraphs are defined with the <p> tag. Paragraph tag is a very basic and typically the first tag you will need to publish your text on the web pages. Here’s an example:

<p>This is a paragraph.</p>
<p>
   Paragraphs are defined with the <p> tag. Paragraph tag is a
   very basic and typically the first tag you will need to publish
   your text on the web pages. Here's an example:
</p>

<div> Tag

The <div> tag is a container for HTML elements, which can be styled with CSS. It is often used to group elements together to apply styles to multiple elements at once. Div tag has both open(<div>) and closing (</div>) tag and it is mandatory to close the tag. The Div is the most usable tag in web development because it helps us to separate out data in the web page and we can create a particular section for particular data or function in the web pages.

  • Div tag is Block level tag
  • Div tag is used to the group of various tags of HTML so that sections can be created and style can be applied to them.
<div>
     <p>Welcome to Fullstackadda </p>
</div>

<span> Tag

The <span> tag is also a container for HTML elements, but it is an inline element, which means it only takes up as much width as necessary, rather than taking up the full width of its parent container like a <div> would. It is often used to apply styles to small portions of text within a block of text.

The difference between the span tag and the div tag is that the span tag is used with inline elements whilst the div tag is used with block-level content.

Here is an example of using the <span> tag to change the color of a word within a sentence:

<p>The <span style="color: red;">red</span> Welcome to fullstackadda.com</p>

Difference B/W HTML div tag and span tag HTML Paragraph

Here is a table that summarizes the main differences between the <div> and <span> tags in HTML:

<div> tag<span> tag
Block-levelYesNo
Inline-levelNoYes
WidthTakes up the full width of its parent containerTakes up only as much width as necessary
Line breakCreates a new line after itDoes not create a new line after it
Use caseUsed to group related elements together and create a container for other elementsUsed to group a small part of the text and apply CSS or JavaScript styles to it

  • The <div> tag is a block-level element, which means that it takes up the full width of its parent container and creates a new line after it. It is commonly used to create a container for other elements, and it can be used to group related elements together.
  • The <span> tag is an inline element, which means that it takes up only as much width as necessary and does not create a new line after it. It is commonly used to group a small part of the text and apply CSS or JavaScript styles to it.

In short, the <div> tag is used to create a container for other elements, while the <span> tag is used to group a small part of the text.

HTML Paragraph HTML Paragraph

html paragraph
  1. Paragraph element is used to publish text on the web pages. Paragraphs are Block-Level elements.
  2. The div tag is used in HTML to make divisions of content in the web page like (text, images, header, footer, navigation bar, etc).
  3. The HTML span tag is used for grouping and applying styles to inline elements.