HTMLs Tutorial

HTML Tutorial HTML Tags HTML Basic Tags HTML Attributes HTML Elements HTML Formatting HTML Text Format HTML body tag HTML samp tag HTML script Tag HTML section tag HTML select tag HTML source tag HTML span tag HTML strike tag HTML strong tag HTML style tag HTML sub tag HTML summary tag HTML sup Tag HTML svg tag HTML table tag HTML u tag HTML Headings HTML Paragraphs HTML wbr tag HTML Anchor HTML Image HTML Lists HTML Ordered List HTML Unordered List HTML Form HTML Form input HTML with CSS HTML Layouts HTML References HTML Frames HTML Links Fieldset Tag in HTML Basic HTML Tags Br Tag in HTML Free HTML Templates How to Create a Table in HTML HTML Calendar HTML Card HTML Cellspacing HTML Center Image HTML Checkbox Read-only HTML Cleaner HTML Code for a Tab HTML Comment HTML Compiler HTML Nested Forms HTML Overlay Text on the Image HTML Select Option Default HTML Snake Game HTML Subheader HTML Tab Character dd Tag in HTML How Many HTML Tags are There HTML Align Tag HTML Responsive HTML Tab Code HTML Table Alternate Row Color HTML Table Fix Column Width Contact HTML DL Tag in HTML How to Insert Image in HTML HTML Background Color HTML Dark Mode How to Convert HTML to PNG HTML Data Toggle HTML Email Template HTML Font Color HTML Font Family ID and Class in HTML HTML Tab Space HTML Tab Tag HTML Itemprop HTML Itemscope HTML Form Design HTML Input Only Numbers HTML Textarea HTML to JPG HTML to Markdown Python li Tag in HTML MDN HTML What is the Correct HTML for Making a Hyperlink? What is the Root Element of an HTML Document How to Make a Box in HTML How to Save HTML Files in Notepad How to Align Text in HTML How to Change Font Color in HTML? How to Change Font Size in HTML How to Change Image Size in HTML How to Create a HTML Page How to Create a Link in HTML File? How to Create an HTML File? HR Tag in HTML HTML Base Tag HTML Default Attribute HTML Hyperlink HTML Indent HTML Injection Payloads HTML Input Numbers Only HTML Roadmap HTML Row Height HTML Schedule HTML Space HTML Tab HTML vs HTTP HTML5 API HTML5 Video HTML Collection to Array Text Area in HTML

HTML5 Advance

HTML5 Tutorial HTML5 Tags HTML Button Tag HTML canvas Tag HTML caption Tag HTML City tag HTML Tag HTML5 SVG HTML Event Attribute HTML5 Audio HTML5 Youtube HTML5 Button Tag HTML5 Tags

Misc

How to add JavaScript to HTML How to change font in HTML How to change text color in HTML HTML Date HTML Hide Element HTML Nested Table HTML Reset Button What does HTML stand for? HTML Background Image HTML Tag Div Tag in HTML How to insert Image in HTML How to create a link with no underline in HTML How to insert spacestabs in text using HTMLCSS HTML tag HTML Code HTML Tag HTML Canvas Design a tribute page using HTML and CSS What is a Container tag Font tag in HTML Difference between HTML and DHTML Empty Tag in HTML HTML Button Link Html Line Break Img src HTML Nested List in HTML Placeholder in HTML TD in HTML HTML Space Code HTML Target Attribute HTML Tag Markup Meaning in HTML Border-Collapse in HTML HTML Onclick Online HTML Compiler Convert HTML to PDF HTML Formatter HTML5 - Web Storage HTTP – Responses Container Tag in HTML DL Tag in HTML Horizontal Rule HTML HTML Tab Text Html Table Cell Background Color HTML Table Cell Color HTML Col Width How Many HTML Tags are There Convert String to Unicode Characters in Python HTML Runner HTML Style Attribute HTML Superscript Attribute HTML tabindex Marquee Tag in HTML HTML Dynamic Form HTML side Tag HTML Pattern Attribute HTML q Tag HTML Readonly Base 64 Encoding in HTML Documents Enhancing Data Portability and Security Evo Cam Web Cam HTML Free code camp HTML CSS How to Add a JS File in HTML? How to Add Picture in HTML How to Add the Logo in HTML? How to Add Video in HTML HTML Class Attribute HTML Entities HTML Form Elements HTML Form Templates HTML Marquee Tag HTML Radio Buttons HTML Text box HTML to JSX HTML Tooltip Basic HTML Codes How to Align Image Center in HTML HTML Header Tag HTML Image Tag HTML Next Line

HTML Indent

What does indentation mean?

The gap that appears at the start of a line to aid in visually identifying code groupings is called indentation. It is comparable to how ideas and thoughts are divided into English paragraphs and line breaks. 

HTML indentation

HyperText Markup Language or HTML is not particularly concerned about white space. This implies that the browser will ignore any extra space or line breaks you add. However we have to manually indent our HTML code for readability. 

What makes Indentation crucial?

Let's first examine the importance of indentation in HTML before getting into its specifics. Consider reading a book without any line breaks, paragraphs, or spaces. We mean that would be a nightmare. Similar to this, indentation aids in code organization and makes it simpler to understand and debug in the domains of programming and HTML. 

What do we make?

We will learn how to indent information in HTML in this post. The following two properties are yours to use: 

margin-left: This style indents a whole text block. 

text-indent: The text's initial line alone has to be indented. 

The Fundamental indentation principle

Every nested tag in HTML should be indented one level deeper than its parent tag, according to the fundamental rule of indentation. A tag enclosed in another tag is referred to as a "nested" tag. We take the words "parent" and "child" from family trees where a parent tag contains one or more kid tags.

Take a look at this HTML code, for example:

 <div>

<p>Hello world</p>

</div>

The parent tag in this instance is <div>, while the nested or child tag is <p>. Compared to its parent <div>, the child tag <p> has one level more indentation.

In HTML, how do we indent?

First example: Making use of the margin-left feature

An element's left margin is increased by using the margin-left attribute. The entire block of text is indented to the necessary extent. Both absolute and relative numbers can be used to specify the quantity of space. 

Text indentation in HTML may be accomplished with an inline style. The paragraph tag's whole content is indented 25 pixels to the left in the example which uses margin-left. 

<h3>

What does HTML mean?

</h3>

<p style="margin-left: 20px;">

HTML stands for HyperText Markup Language. It is a popular markup language for building web pages. It facilitates the creation and arrangement of sections, paragraphs, and links through the use of HTML elements, which are the essential building blocks of a webpage. These elements include tags and properties.

</p>

Output

HTML Indent/>






<p><strong>Example 2: Using the Text-indent property<br></strong>A paragraph's initial line of text is separated from the left by the text-indent property. Absolute or relative numbers can be used to provide the needed amount for HTML indent.<br><br>Text indentation in HTML may be accomplished with an inline style. The paragraph tag's first line is indented 25 pixels from the left in the example which makes use of text indent.</p>






<pre class=<h3>

What is HTML?

</h3>

<p style="text-indent: 20px;">

For HyperText Markup Language, see HTML. It is a common markup language utilized to create web pages. Utilizing HTML elements, which are the basic parts of a webpage, such as tags and attributes that permits the construction and organization of paragraphs, sections, and connections.

</p>

Output

HTML Indent/>






<blockquote class=

Note: The CSS elements text-indent and margin-left are named after their corresponding inline HTML attributes. Hence, the desired selection in CSS contains a mention of the attributes and their values. To incorporate the CSS code, use an external stylesheet or the style tag in the HTML head.

Frequently Used HTML Indentation Examples

Unordered List

Two spaces are used to indent the <li> elements to the right when they are nested inside their parent <ul>.

Well-known programming languages are:

<ul>

  <li> Java </li>

  <li> C </li>

  <li> Python </li>

</ul>

Output

HTML Indent/>






<h3 class=Ordered lists

Two spaces are utilized to indent the <li> components to the right when they are nested inside their parent <ol>.

Places to visit in India

<ol>

  <li>Delhi</li>

  <li>Manali</li>

  <li>Kerala</li>

</ol>

Output

HTML Indent/>








<h2 class=In summary
  1. The space in a text block that appears between the start and the margin of a line is known as indentation.
  2. The appropriate indentation value may be set with the aid of the HTML text-indent attribute.
  3. <li> elements under <ol> and <ul> have an HTML indent.
  4. The text-indent property is applied as an inline style in HTML whereas it is applied via the selector rule in CSS.
  5. Text-indentation values can take two forms: absolute, such as pixels (px) or relative, such as em, rem or percentage of the element's total width.
  6. While text-indent indents the initial line of the paragraph, margin-left indents the whole text block.