Do <div> elements increase the complexity of our HTML structure?

Question

Adding <div> elements to our HTML document doesn’t seem to change anything on the page. What’s the point of nesting other elements within a <div>? Doesn’t this just increase the complexity of our HTML structure?

Answer

When using <div> tags as containers, it is true that our nesting might become more complex. However, the benefit is that if we create a thoughtful HTML structure we can more readily parse and target related content. In other words, there is often a trade-off between complexity and either readability or targetability. As developers, we want to find the right balance between creating enough coherent structure to enhance readability and targetability without venturing into “divitis” territory.

41 Likes

2 posts were split to a new topic: What does a

mean