> (if (>= emacs-major-version 27)
>     (defface foo...) ; for Emacs 27 and later
>   (defface foo...)   ; for Emacs 26 and older

This results in lots of code duplication. Maybe it's better to:

(defface foo...)
(when (>= emacs-major-version 27)
  (set-face-attribute foo... :extend t))

I'm not elisp expert by any means.
--
Best regards,
Andrey Orst