Not a geek or super expert. But began building sites 20+ years ago, before CSS came along.
While CSS is a blessing, I’ve always been annoyed by the “invention” that emerged way back then, the stupid (imho) habit of creating menus as lists.
Now, I’m sitting here with an open source app, going bananas. In desktop view (i.e. over about 1000px screen width) I want the menu and menu items centered and equally wide in % or vw. And same distance between them. Of course lined up horizontally.
I have tried e.g. “flex”, “columns” and “display:table” with umpteen different variations to no avail.
Well, I dived into the source code files and created two different menues. One without li and ul, but simply as regular links (a) for screen widths 1100px and wider, then another with those f***ng uls and lis for widths 1099px and less. It’s working fine.
Pardon me for ranting. But it annoys my a** off that the www consortium hasn’t created a certain tag for menues and menu items. They have created numerous different and somewhat obscure tags as standard that aren’t used by a fraction of all sites. Fine! But the most common need and required by 99.9999% of all sites is a menu. Still, we have to use ul and li which have a completely different purpose.
www, if anyone of you read this: Make a special menu code.
Making two versions of the menu with different mark up is totally unnecessary. CSS is more than capable of handling this.
It strikes me that you may still have the pre-CSS mindset of thinking about HTML tags based on their default browser styling. CSS doesn’t care what tags you use, or how they appear by default, because it has the power to completely transform their appearance to whatever you like.
You can make a table look like a list, you can make a list look like a table. You can make <small> text look like a huge banner heading if you were so inclined. Possibilities are endless.
So you could make a menu out of divs and spans or whatever tags, and style them however you want it to look.
But the choice of tags should always come down to semantics. A menu, by definition is a list, therefore we use list elements for menus. Again, how that list appears on screen is entirely up to you, CSS can do it.
Wrong. A menu is not a list by some kind of universal definition. In html, a list is a list. How I want a list to appear, as in my case, i.e. with list items equally distributed, equally sized and centered in the ul is a nightmare since different browsers on different platforms treat the ul and li attribute differently. As soon you wrap a link in a div instead of under a ul and li and then use css to style and position, it works just fine cross browser and cross platform.
That’s news to me! Are you able to elaborate with examples please as I would be interested to see?
If you have proof of your statement then it would be good to discuss the issues and see if we can work out what the problem is. We love problem solving here on the forums. :). Please show us the div structure that you say a list can’t replicate just as easily.
Css doesn’t really care if its a UL or a LI and will style then just like you would with a div. The only differences with a list structure are margins, padding and bullet points but you can change all those with css very simply.
Lists are 100% compatible cross browser/platform and unless you can provide an example where they cause problems I’m afraid I will have to disagree strongly with you as I never had a problem with them in many years of use.
One thing I didn’t see mentioned here is that the <ul> element has left-padding applied. It’s what indents the list items. This has thrown me off more times than I can count. I’d recommend simply adding padding-left: 0; to your CSS on the UL element and see if that helps. Just setting padding:0 doesn’t work, you have to explicitly override padding-left.