Here is how Emacs determines the face to use for displaying any given piece of text:
region face. See Standard Faces.
nil face
property, Emacs applies the face or face attributes specified by that
property. If the overlay has a mouse-face property and the
mouse is “near enough” to the overlay, Emacs applies the face or
face attributes specified by the mouse-face property instead.
See Overlay Properties.
When multiple overlays cover one character, an overlay with higher priority overrides those with lower priority. See Overlays.
face or mouse-face property,
Emacs applies the specified faces and face attributes. See Special Properties. (This is how Font Lock mode faces are applied.
See Font Lock Mode.)
mode-line face. For the mode line of a
non-selected window, Emacs applies the mode-line-inactive face.
For a header line, Emacs applies the header-line face.
default face.
If these various sources together specify more than one face for a
particular character, Emacs merges the attributes of the various faces
specified. For each attribute, Emacs tries using the above order
(i.e., first the face of any special glyph; then the face for region
highlighting, if appropriate; then faces specified by overlays, then
faces specified by text properties, then the mode-line or
mode-line-inactive or header-line face, if appropriate,
and finally the default face).