The Commonwealth War Graves Commission honours the dead from the two world wars.
On it’s website there is a free to search database of the 1.7 million who died, filterable by firstname, surname, cemetary, date of death and force.
You can also search a specific cemeterary from 23,000 they have listed.
This is a great place to start your search for an ancestor who may have died in battle.
Obviously their database is limited to these records, so you won’t see any records of those injured, or any additional data that you will most likely see elsewhere, but as a free resource you won’t get much better.