The Developer Brains


HTML Paragraphs

Web Designing | Web Development


SEE MORE














</HTML Paragraph>





Do you know ?


Paragraphs are the most basic HTML element. This topic explains and demonstrates the usage of the paragraph element in HTML. b
<p> 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>
				
				

Try it Yourself

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 Click here



SEE MORE




















</Some Examples Paragraphs >


Exapmle 1 with spaces

Browser remove extra spaces ,you can only add 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 lines breaks when the page is displayed
Here is a simple code example of a 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>
				
				

Try it Yourself





Example 2 with line break

Just like extra spaces browser remove/ignore line braeak 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 synthx 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>
				
				

Try it Yourself




Example 3 with preformated paragraph

Some time we want to display our paragraph same as written in source code for example we are writing 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>
				
				

Try it Yourself













Next: HTML Text Formatting


Previous

      

Next Page













  Share TDB SCHOOL  

Share this E-Learning Website on social media platforms with your friends and followers