Let there be less divs
See original GitHub issueNow that CSS grid is out and we’re finally able to implement sites semantically and lay out stuff nicely without enormous amounts of divs and hacks it would be very nice to see this principle followed in frameworks such as next.js. Unfortunately that’s not the case at the moment.
I’m currently following the tutorial and I already have…
<body>
<div>
<div id="__next">
<div data-reactroot="" data-reactid="1" data-react-checksum="315191458">
<!-- my content full of wrapper divs because of react.js -->
</div>
<div id="__next-error"><!-- guess this exists only in dev mode -->
</div>
</div>
<div>
<script>...</script>
...
</div>
<script>...</script>
</body>
Expected Behavior
I think only div we should have is the react root div.
Current Behavior
I see a few unnecessary looking divs.
Steps to Reproduce (for bugs)
- Follow the first tutorial until it works.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:28
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Let there be less divs · Issue #2708 · vercel/next.js - GitHub
I think only div we should have is the react root div. Current Behavior. I see a few unnecessary looking divs. Steps to...
Read more >Stop using so many divs! An intro to semantic HTML
My point in this thread was to let you know that there is a very real difference between arbitrary nonstandard elements, which have...
Read more >CSS how to fill remaining space (1 div with smaller divs)
It may look good at 100% but when zooming, they will almost always give rounding errors. I would recommend using pixels or em's....
Read more >Semantic HTML Guide – 10 Alternatives to Using divs
You can also use a footer element as a closing within a <section> element. Less common alternatives to div. There are also some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in canary.
<>
can’t be used yet because it requires the beta version of babel. Which we’ll integrate in next.js v6.would recommend a small edit to the workaround by @lancejpollard:
This is to avoid the #__next-error div blowing up to 100% as well.
This is pretty darn hacky though. 😦 I would rlly appreciate it if the div inside of body could at least have a className, so I don’t have to try to target it using body > div:first-child which feels bad to do