Please support if you like my work by payment through upi: sinhamit@icici or payment by bank
account name: Amit Kumar Sinha,
account number: 2646728782
IFSC code: KKBK0005660
SWIFT: KKBKINBB
Inline Level HTML Elements in Category: HTML by amit
🕙 Posted on 2023-04-11 at 18:39:55 Read in Hindi ...
Inline Level HTML Elements:
Inline level HTML elements should be, generally, used inside BLOCK LEVEL elements, so that TEXTs, Images, etc. will be shown correctly. Various INLINE level HTML elements are explained below:
<p> Paragraph Element </p> is a BLOCK level HTML element, and contents, texts, etc. inside paragraph element, with <br /> (an empty HTML element) <!-- 1 --> will make a line break. Thus, you can say, <br /> as INLINE LEVEL element.
Any blank (white/
is used for making blank (white)-spaces inside HTML element <!-- 3 -->, except inside <pre> PRE-FORMATTED element </pre> . You should use PRE-FORMATTED tag, generally, for making spaces and new lines.
However, when you are working in any CMS (Content Management System, for example, WordPress, or custom designed CMS), you can insert line-break and spaces with Enter / Return and spacebar keys, because in PHP, functions like htmlentities()
or other similar functions in Python, etc. are used by the CMS.
<hr /> is a block-level element for drawing a horizontal line, and it should only be inserted inside BOX type HTML elements (see previous page). The web-browser will end / close the <p> Paragraph Opening tag, with </p> when <hr /> tag is inserted inside the Paragraph element.
You can see different font styles in above and this line, because <hr /> is an empty element, which is inserted inside the <p> Paragraph Element </p>
. You can also inspect this in your web-browser, by moving your mouse to top-right of your web-browser, e.g., Google Chrome, and clicking ⋮ (at top-right) ⇒ More Tools ⇒ Developer Tools with left-
<pre> Pre Formatted Texts </pre> is also BLOCK level HTML element.
<span> </span> is an INLINE level HTML element, which behaves just like DIV element. It also has no visual existence, just like other BOX type HTML elements. It also represents children, that is, contents / texts inside it.
In the previous page, you have seen that DIV element (a block level element,) can also be used as an inline HTML element, because DIV is nothing but represents its children, and following code explains the same:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>R.I.B.H.U. Academy</title>
<style type="text/css">
/* === EMBEDDED CSS STYLES === */
h1 { color: khaki; }
.heading { color: red; }
#id_head { color: green; }
</style>
</head>
<body>
<h1 style="color: blue;" id="id_head" class="heading">Exercise: Inline Level HTML element</h1>
<!-- 2. blank spaces --> <p> This is a line of text without displaying multiple (blank) white-spaces.</p>
<!-- 1, 3 --> <p> This is a line of text , <br /> with multiple (blank) white-spaces and one line-break inside it.</p>
<!-- Except of <pre> </pre> element, blank (white)-spaces and line-break inside an HTML element, is inserted as explained above. -->
<pre>
This is a pre-formatted
line of text.
</pre>
<!-- Caution: Remember, when you add indentation while working in any TEXT / CODE Editor (including VSCode Editor), <pre> </pre> will also add those indentation and texts / contents will be shown unexpectedly weired. -->
<div><!-- start: Outer DIV -->
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis accusantium at blanditiis quasi tempora doloremque distinctio perferendis corporis architecto quo repudiandae aperiam officiis, reiciendis soluta delectus numquam placeat.</p>
<div style="background-color: pink; float: right; width: 300px;"><!-- start: Inner / Nested DIV -
float
property in CSS should be used with width
property, and you will see that contents inside that HTML element, will be moved to left or right. --><p>At illo temporibus tenetur hic architecto earum quas fugit, quasi enim soluta unde praesentium aut maiores recusandae voluptatum magnam eum, odio modi omnis numquam?</p>
<p>Ratione illum minima, incidunt et adipisci reiciendis voluptatum eum repudiandae impedit, maxime sed qui rerum temporibus animi consectetur quia iusto vero dolorem veritatis consequatur explicabo soluta mollitia eius? Soluta, ad.</p>
</div><!-- end: Nested / Inner DIV -->
<p>Illo quos voluptates, id nam recusandae provident veritatis? Ipsum temporibus similique voluptates excepturi eum? Voluptates necessitatibus quasi voluptatibus.</p>
</div><!-- end: Outer DIV -->
<div><!-- start: 2nd Outer DIV - in this illustration, don't use <p> </p> element, because it is also a BLOCK level element. -->
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis accusantium at blanditiis quasi tempora doloremque distinctio perferendis corporis architecto quo repudiandae aperiam officiis, reiciendis soluta delectus numquam placeat.
<div style="background-color: yellow; display: inline;"><!-- start: Inner / Nested DIV -->
At illo temporibus tenetur hic architecto earum quas fugit, quasi enim soluta unde praesentium aut maiores recusandae voluptatum magnam eum, odio modi omnis numquam?
<!-- 2. new line --> <!-- Create next line with
Enter
or Return
key -->Ratione illum minima, incidunt et adipisci reiciendis voluptatum eum repudiandae impedit, maxime sed qui rerum temporibus animi consectetur quia iusto vero dolorem veritatis consequatur explicabo soluta mollitia eius? Soluta, ad.
</div><!-- end: Nested / Inner DIV -->
Illo quos voluptates, id nam recusandae provident veritatis? Ipsum temporibus similique voluptates excepturi eum? Voluptates necessitatibus quasi voluptatibus.
</div><!-- end: 2nd Outer DIV -->
<script type="text/javascript">
// JavaScript codes ...
</script>
</body>
</html>
Explaination:
In the above example, you can see that first <p> </p> element, ( just after <h1></h1> ) has texts with many blank (empty/
Texts inside <pre> </pre> having extra white-spaces and new-line (with Enter key) are shown in web-browser, as much white-spaces and new-line are inserted with keys in keyboard.
The nested DIV (having PINK background) inside first outer DIV is moved to right.
The nested DIV (having YELLOW background) inside second outer DIV is enclosed with previous and next TEXTS (contents) outside it. (See result in Example page.)
REMEMBER
: Each HTML element, whether BLOCK level or INLINE level has its own default properties (assigned by different WEB BROWSERs differently). You also can assign default properties to TEXTs as how much size they have, which font-family should be displayed as default, etc. in your web-browser, e.g., Google Chrome, by clicking ⋮ (at top-right) ⇒ Settings ⇒ Appearance ⇒ Customize fonts with left-
You should not change these settings, especially Font-size to Tiny (9) or Huge (72), otherwise you will see very tiny font-size or very huge font-size of each website or web-page. Reset all settings of your web-browser, if you are uncomfortable with any changes.
Leave a Comment:
Amit Sinha March 2nd, 2023 at 9:30 PM
😃 😄 😁 😆 😅 😂 😉 😊 😇 😍 😘 😚 😋 😜 😝 😶 😏 😒 😌 😔 😪 😷 😵 😎 😲 😳 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 😤
Ribhu March 3rd, 2023 at 9:30 PM
🐵 🐒 🐶 🐩 🐺 🐱 🐯 🐅 🐆 🐴 🐎 🐮 🐂 🐃 🐄 🐷 🐖 🐗 🐽 🐏 🐑 🐐 🐪 🐫 🐘 🐭 🐁 🐀 🐹 🐰 🐇