问题
I'm busy writing an online chat, and although it doesn't really matter which I use, since I can style them however I want with CSS, I'd quite like to use the best tag for messages.
My first thought was to use an <ol>
since the messages are ordered by time. However, Facebook uses <ul>
s and Google chat uses <div>
s. Twitter does use <ol>
.
So, which is semantically correct? And, which would be best for user with screen readers?
回答1:
div
only. <ul><ol>
are lists. Chat messages are not ordered list, it is obvious. If you dont need bullets/dots/other marker near each message - they are not unordered list too.
Also using div
you dont need to reset default styles for lists = less CSS code you will write.
来源:https://stackoverflow.com/questions/15966272/online-messaging-ul-vs-ol-vs-div