I’m new to HTML. When I started reading documentation about lists, I’ve noticed that everywhere an <ul>, <li> structure is used, even for creating very simple lists.
But for me it’s most comfortable to use only <a> elements with CSS:
display: block;
/* and/or */
float: left;
So, why use <ul>, <li> instead of just <a>?
Thanks a lot.
Because structurally they’re the most appropriate elements for that purpose. Also helps screen reader users in terms of properly dictating the elements of a page.
Remember that HTML is for markup/content ( what IS this text? a paragraph? wrap it in a p tag ), CSS is for styling, JS is for behaviour.
You can have thousands of anchors on your web page, but what if you want to style anchors nested within listed items differently from other anchors?
If you had done things properly, your css would be trivial to implement
Otherwise you’d have to throw classes around anchors and it would be messy and unstructural.
In regards to the SEO – I believe that in the past semantically marked up code didn’t have much bearing but nowadays with specs like RDF, HTML 5 elements the web is getting more and more semantic, so it’s only beneficial to be as semantic as you can be.