+ 7
What are Block-level and inline elements in HTML and what is the difference between then?
7 Réponses
+ 8
Simply put, block-level elements are those HTML elements that require a new line before they can be used and they take full width and height
WHILE
Inline elements are those HTML elements that do not require a new line before writing em i.e they can be inserted between other tags and only take minimum width and height.
Another difference is that inline elements can be inserted into block-level elements
For example
<p>This is a <b>paragraph</b> with <i>this word italicized</i></p>
In the example above, block-level element p contained inline elements <b> and <i>
The opposite is quite impossible (i.e inline elements cannot contain block-level elements)
Hope this helped
+ 29
In HTML course of sololearn it is explained.
I think we must read the lessons first then post questions
+ 7
A search here or on the web will give you answers.
+ 4
Block elements are the elements, after which a line break is put when you run the code.
Inline -> stays in-line.
Example:-
<p> x </p>
<p> y </p>
OUTPUT:-
x
y
See? New line (break tag) automatically after the paragraph. Thats a block element.
<p> hi <i>Diksha </i> sup</p>
Output:- hi Diksha (in italics) sup
See? No new line after Diksha, coz i is inline element.
+ 2
inline=tags remaining in line, flowing from left to right.e.g span/em inside of a p tag,
block = normally stack on top of each other. e.g. a div next to a p tag.
principles:
use inline elements inside block elements. not the other way around.