Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Online Messaging: <ul> vs <ol> vs <div>

Tags:

html

semantics

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?

like image 681
Swadq Avatar asked Jan 30 '26 21:01

Swadq


1 Answers

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.

like image 195
bravedick Avatar answered Feb 01 '26 13:02

bravedick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!