FOLLOW US ON TWITTER



FOLLOW US



img/blogimg/html5.jpg


@coder 728

What is the use of HTML Paragraphs Tag


2021-10-12 12:34 · 7 min read

Do you know?

Paragraphs are the most basic HTML Elements. This topic explains and demonstrates the usage of the paragraph element in HTML. 
A <p> tag represent the paragraph in webpage .

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- simple example of paragraph-->
<p>This is a simple paragraph </p>
<!-- simple example of multiline paragraph-->
<p>TDB School is a leading web developer's website.
Here you will learn how to code amazing, modern, responsive,
and attractive (static and dynamic) websites by using the latest
web technologies</p>
</body>
</html>

Note: Browser will remove any extra spaces and extra lines when the page is displayed .If you want to add extra space or a line break ,you have use &nbsp; (non breakable space) and br for line break.
Do you want to lean more about HTML Character Entities.

 

</Some Examples Paragraphs >

Exapmle 1 

with spaces

Browser removes extra spaces, you can only add a single space that's why you cannot change the output by adding extra spaces or extra lines in your HTML code. The browser will automatically remove any extra spaces and line breaks when the page is displayed
Here is a simple code example of Extra spaces.

<p>
This example paragraph which
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>

 

How to add extra spaces in our paragraph ?
So the question is , can we add some extra spaces in our paragraph . In some cases we want to add some extra spaces , but as we ready above browser remove extra spaces thats why HTML Intruoduce HTML Character Entities so give us for power to represent our document.
In HTML some characters are reserved we can't represent them in our document directly such as : less than (<) or greater than (>) signs in your text, the browser might mix them with tags.
Character entities are used to display reserved characters in HTML
click here learn more about HTML Character entities.

We use &nbsp; (non-breaking space) to add single extra space 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!--Exapmle 1 with spaces-->
<p>
This is a paragraph, extra spaces will be removed by browsers
</p>
<!--The browser will automatically remove any extra spaces-->
<!--USING &nbsp; to add extra spaces-->
<p>This is another &nbsp;&nbsp;&nbsp;&nbsp;paragraph, extra
&nbsp;&nbsp;&nbsp;&nbsp;spaces will be removed by browsers</p>
<!--Exapmle 1 with spaces-->
</body>
</html>

 

Example 2 

with line break

Just like extra spaces browser remove/ignore line break also.

<p>
This example paragraph which
contains

lot of line breaks
in the source

code,

but the browser
ignores it.
</p>

Info: So we use <br> tag for line break ;

Note: You can use both syntax of br ( <br> and </br> )

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body><!--Exapmle 2 with line break -->
<!--The browser will automatically remove all line break and text will be display in single line-->
<p>
Browser

ignores line break.
</p> <!--USING <br> to add break lines-->
<p>
so we use <br> for line break
</p>
<!--Exapmle 2 with line break -->
</body>
</html>

 

Example 3 with preformatted paragraph

Sometimes we want to display our paragraph the same as written in source code, for example, we are writing a poem but we know that Browser will remove any extra spaces and extra lines when the page is displayed.

<pre>
The plates will still shift
and the clouds will still spew.
The sun will slowly rise
and the moon will follow too
</pre>

Info: In this situation we use <pre> tag .
 

<pre> defines as preformatted text.


The <pre> element is displayed text as it is written in source code with extra spaces and line breaks ,it preserves both spaces and line breaks 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- Example 3 with preformated paragraph-->
<!-- The <pre> element is displayed text as it is written in source code with extra spaces and line breaks -->
<pre>
The plates will still shift
and the clouds will still spew.
The sun will slowly rise
and the moon will follow too
</pre>
</body>
</html>
TAGS:






POST COMMENTS
No Comment

Please login to post comment




POPULAR POSTS

best free web hosting services...
what is new in miui 11?...
free website ssl security using cloudfla...
do you want to make money online?...
CSS3 @IMPORT RULES...
What is HTML Anchor Tag and Hyperlinks?...
How to host a web page in 10 minutes....
CSS3 RESPONSIVE UI...
Tables HTML...
CSS3 FUNCTIONS...
How to use CSS3 Overflow Property?...
CSS3 FILTERS...


RECENT COMMENTS

2022-03-05 11:05
By coder on XAMPP - MySQL shutdown unexpectedly | How to fix MySQL crash unexpectedly
2021-10-12 12:34
By abnongoke on do you want to make money online?
2021-10-12 12:34
By abnongoke on how to get a free website domain name?
2021-10-12 12:34
By solar panel for shed on what is new in miui 11?
2021-10-12 12:34
By solar panel for shed on best free web hosting services
2021-10-12 12:34
By amos tanui on free website ssl security using cloudflare


SOCIAL SHARE



FOLLOW US ON TWITTER



FOLLOW US ON FACEBOOK



FOLLOW US







Recent Blogs



Contact Us

Subscribe Our News-Letter



Kashipur, 244713
Uttarakhand, India



© www.prodevskill.com 2023. All Rights Reserved. Powered by Pro Developer