News for hackers. Stuff that matters.

Ask HN: For simple layouts, do I need CSS Flex or Grid?

For a simple one-dimensional blog layout (header -> navigation -> content -> footer), do I need to use these new CSS APIs? Will CSS's default behaviour continue to work in the future, or are all sites expected to use these new systems?
( 4 comments | on HN )
Re:Ask HN: For simple layouts, do I need CSS Flex or Grid? by gardenhedge on Friday November 04, 2022 @08:37PM (#33476283)
I'm not sure about the future state of CSS but I choose to use Grid as often as possible these days.
Re:Ask HN: For simple layouts, do I need CSS Flex or Grid? by solardev on Friday November 04, 2022 @11:55PM (#33477767)
By default divs are blocks. If you don't want flex or grid, you don't have to use them. In fact you don't have to use CSS at all if you don't want to. You can write plain HTML if you prefer.
Re:Ask HN: For simple layouts, do I need CSS Flex or Grid? by approxim8ion on Saturday November 05, 2022 @03:36PM (#33484810)
I prefer flex, but that's just because I'm more used to it, and I work a lot in angular where the angular-flex-layout shortcodes reduce effort a lot.
Re:Ask HN: For simple layouts, do I need CSS Flex or Grid? by bhdzllr on Saturday November 05, 2022 @05:56PM (#33486290)
No, you don't need it if you use block-level elements (like div, header, nav, main, footer). Block elements always start on a new line and are therefore always one after the other in a column direction. This is part of HTML and will not go away.

Here is a simple example without styling:

https://jsfiddle.net/3g71hLf0/2/

And with some styling:

https://jsfiddle.net/3g71hLf0/1/