Div and Span (<div>, <span>)

When To Use

  • Used for layout or styling purposes. Other then that, they lack any semantic meaning. 2 1

Rules

  • The <div> element is inherently considered to have a generic role, rather than none. This could potentially impact certain ARIA combination declarations, as they rely on the presence of a descendant element with a specific role in order to function correctly. 1
  • The <div> element is recommended to be used solely when there is** no other suitable semantic element available**, such as <article> or <nav>. 1
  • Avoid attempting to substitute every <div> or <span> with semantic elements, as elements that are exclusively employed for layout or styling objectives should not possess any additional semantic significance. 3
  • The <span> element is similar to the <div> element, however, <div> elements are block-level elements whereas <span> elements are inline elements. 2

Sources 

  1. MDN: <div>: The Content Division element by Mozilla contributors is licensed under CC-BY-SA 2.5
  2. MDN: <span>: The Content Span element by Mozilla contributors is licensed under CC-BY-SA 2.5
  3. Segunolalive: Improving Accessibility With DIV and SPAN by Segun Ola is licensed under Creative Commons Attribution 4.0 International License
Created at: 19.04.2023, Last updated at: 11.06.2023