1. What the "online" indicator exactly means
When you open a chat and see the word "online" below your contact's name, all WhatsApp is telling you is that that person has the app open on their phone at that instant. It doesn't mean they're looking at your conversation, that they've read your last message, or even that they're paying attention to the phone: they could be in another group's chat, browsing the conversation list, or with WhatsApp open in the recent background while doing something else on their phone.
As soon as that person closes the app or goes a while without touching it, "online" disappears and "last seen" appears in its place, with the date and time they were last connected. They're two sides of the same presence indicator: one tells you they're connected right now, the other tells you when they last were if they aren't right now.
2. Why you can't hide "online" without also hiding "last seen"
It's one of the most common questions: a lot of people would like it to not show when they have WhatsApp open, but still keep showing their "last seen" (or the other way around). WhatsApp doesn't allow that natively. Both pieces of data depend on a single setting, the same switch, so they turn on and off together.
To reach that setting, open WhatsApp and go to Settings > Privacy > Last seen and online. There you'll find the options to choose who can see this information: everyone, my contacts, my contacts except... or nobody. If you choose "Nobody", both your "last seen" and your "online" status will stop showing to anyone, without exceptions or extra nuances.
3. Reciprocity: if you hide, you stop seeing others too
Here comes the part that surprises people most the first time they try it: WhatsApp applies a reciprocity rule. If you choose to hide your "last seen and online", you'll automatically stop seeing that same information on anyone else's profile, even if they have it visible to everyone. There's no way to see other people's connection status while hiding your own; that's how WhatsApp works, and there's no setting or official app that gets around it.
Keep in mind too that this setting doesn't affect group chats: inside a group, any member can still see if another participant is "online" at that moment, regardless of their last seen privacy setting, since that piece of data is shown at the individual conversation level.
4. "Online" and the two blue checkmarks aren't the same thing
It's easy to confuse the two indicators because both have to do with the contact's activity, but they answer different questions. "Online" is a general status for the person: it tells you if they have the app open right now, with no connection to any specific message. The two blue checkmarks, on the other hand, are the read confirmation for a specific message you already sent: they turn blue when that person opens the chat and that message shows on their screen.
That's why you can see someone "online" while your last message still shows a single gray checkmark (it hasn't had its turn to be read within the chat yet), or the other way around: someone can read your message and have the checkmarks turn blue, and a minute later disappear from "online" because they closed the app. They're two independent systems that simply tend to coincide in time.