Difference Between Block level And Inline Elements?
Block Level Elements:
- A block-level element always starts on a new line, and browsers automatically add some
space (a margin)
before and after it.
- A block-level element always takes up the full width available, stretching out to the
left and right as
far as it can.
- Two commonly used block elements are: <p> and <div>.
- The <p> element defines a paragraph in an HTML document.
- The <div> element defines a division or a section in an HTML document.
Here is a list of block-level elements in HTML:
<address> <article> <aside> <blockquote> <canvas><dd> <div> <dl> <dt>
<fieldset> <figcaption> <footer> <form> <h1> <h6> <header> <hr> <
li> <main><nav> <noscript> <ol> <pre> <section> <table> <tfoot> <ul> <video>
- These elements typically start on a new line and take up the full width available in the
parent
container
Inline Elements:
- Inline elements do not start on a new line.
- An inline element only takes up as much width as it needs.
- This is a <span> element inside
a paragraph.
Here is a list of inline elements in HTML:
<a> <abbr> <acronym> <b> <bdo> <big> <br> <button> <code> <dfn> <em>
<i> <img> <input> <kbd> <lable> <map> <object> <output> <samp> <script>
<small> <span> <strong> <sub> <sup> <textarea> <time> <tt> <var>
NOTE: An inline element cannot contain a block-level element!