Most levels contain secrets. At the end of each level, the percentage of secrets found is displayed on the intermission screen.
Secrets are usually areas that are hidden to some extent. Often, there is some clue about a secret area, such as an off-color wall that is actually a door. By convention, most levels are designed so that it is not necessary to find any of the secret areas to complete the level.
A special sector type (type 9) is used to calculate the secrets-found percentage. The number of type 9 sectors in the level is the total number of secrets. When a player first enters a type 9 sector, the number of secrets found is incremented by one. A secret (or "hidden") area may encompass any number of sectors, but will normally contain only one sector of type 9 in order to give the secrets-found percentage a straightforward interpretation. Some source ports use the type 9 sector to trigger an announcement such as "A SECRET HAS BEEN REVEALED" or to play a sound, but the original game does not give any indication until the intermission screen.
Linedefs have a secret flag bit (bit 5). This flag makes a two-sided linedef appear on the automap in red instead of yellow, that is, just like a single-sided linedef. It used to hide entrances to secret areas on the automap, but has nothing to do with the calculation of the secrets percentage.
In vanilla Doom, a secrets percentage of 0% is ambiguous. Normally, it means the player found none of the secrets, but it could also mean that the level has no secrets to find. Some source ports display 100% in the latter case, to indicate that the player has done as well as possible.