HTML elements are structured into two kinds, which are block elements and inline elements. Block elements contain elements like paragraph, headings, lists, etc... which are in a seperate block. Inline elements are like emphasis, strong, bold elements which can be inside a block or can act separate too.
There are actually certain characteristics for block and inline elements that we must understand.
Block-level Characteristics
- Will always start below the previous element, by default.
- Ignores vertical-align property.
- Parent container's width will be set by default.
Inline element characteristics
- It flows normally.
- They don't have width and height property.
- They do not have top and bottom margin, but can apply left and right margins and also apply any padding.
- If an inline element is floated to right or left, it will be subjected to a block-level element property.
- If fits inside a block element.
- It can contain only another inline element.
But these block and inline element tags that is mentioned above cannot be used in all cases because, the tags are used for a certain functionalities. So, HTML has a flexible inline and block level elements called,
- DIV element
- SPAN element
Using div element
<div id="header">
<!-- some code missing -->
</div>
<div id="content">
<!-- some code missing -- >
</div>
<div id="sidebar">
<!-- some code missing -- >
</div>
<div id="footer">
<!-- some code missing -- >
</div>
The div element has the characteristics of a block-level element. Here, the difference between other block-level elements is that it don't imply any functionality to its elements. It is highly useful only when applying CSS to it.
Using span element
<div class="content">
<!-- some texts missing -->
<span><a href=" ... "> ... </a></span>
<!-- some texts missing -->
<!-- some texts missing -->
<span><a href=" ... "> ... </a></span>
<!-- some texts missing -->
</div>
<span><a href=" ... "> ... </a></span>
<span><a href=" ... "> ... </a></span>
As div has a block element characteristics, span can be used as an inline element within or outside block level elements.
Well hello there! In this post did you use the data from some researches or here are solely your private reflections? Can't wait to see your answer.
ReplyDeleteWell, these are simple HTML and CSS codes that everyone knows about. But it is only that these codes are reflected from my own view...
Delete