Updated:

1. Health below names

/scoreboard objectives add hp health {"text":"❤","color":"red"}
/scoreboard objectives setdisplay below_name hp

Other players see a number such as 20 under your name. One point is half a heart, so full health is 20. In 1.20.1 and earlier, use belowName.

2. Tab list as hearts

/scoreboard objectives setdisplay list hp
/scoreboard objectives modify hp rendertype hearts

3. Sidebar

/scoreboard objectives setdisplay sidebar hp

4. Other values

ValueCriterion
Healthhealth
Hungerfood
XP levellevel
Armor pointsarmor
DeathsdeathCount
Player killsplayerKillCount

health, food, level and armor are read-only and update by themselves. See the scoreboard guide.

5. Hide or remove

/scoreboard objectives setdisplay below_name
/scoreboard objectives remove hp

6. Low health warning (repeating)

/title @a[scores={hp=..6}] actionbar {"text":"Low health!","color":"red"}

Uses the hp objective from step 1. Players at 6 health (three hearts) or less see a red warning above the hotbar until they heal. Add /effect give @a[scores={hp=..6}] glowing 1 0 true so teammates can spot them.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.