HTML Block and Inline Elements


All HTML elements are either display:block; or display:inline; by default.


Block Elements


Block level html elements start on a new line and occupy the entire width of the container they are in. Block level elements also have top and bottom margin.



<div>Block Level Element 1</div>
<div>Block Level Element 2</div>

Live Demo!


Output:
Block Level Element 1
Block Level Element 2


List of block level elements:

  • <address>
  • <article>
  • <aside>
  • <blockquote>
  • <canvas>
  • <dd>
  • <div>
  • <dl>
  • <dt>
  • <fieldset>
  • <figcaption>
  • <figure>
  • <footer>
  • <form>
  • <h1> to <h6>
  • <header>
  • <hr>
  • <li>
  • <main>
  • <nav>
  • <noscript>
  • <ol>
  • <p>
  • <pre>
  • <section>
  • <table>
  • <tfoot>
  • <ul>
  • <video>


Inline Elements


Inline elements do not start on new line and only occupy the amount of space that is needed for its content.



<span>Inline Element 1</span>
<span>Inline Element 2</span>

Live Demo!


Output:
Inline Element 1 Inline Element 2


List of inline elements:

  • <a>
  • <abbr>
  • <acronym>
  • <b>
  • <bdo>
  • <big>
  • <br>
  • <button>
  • <cite>
  • <code>
  • <dfn>
  • <em>
  • <i>
  • <img>
  • <input>
  • <kbd>
  • <label>
  • <map>
  • <object>
  • <output>
  • <q>
  • <samp>
  • <script>
  • <select>
  • <small>
  • <span>
  • <strong>
  • <sub>
  • <sup>
  • <textarea>
  • <time>
  • <tt>
  • <var>