Problem Description
I wish to set a fixed space between header/footer text and the headrule/footrule. I have gone through Setting same distance between header rule, footer rule and text and it is not what I want exactly. For the headers, the space between the last line of the long header text and the headrule is different from the space between single lined header text and the corresponding headrule. In other words, can we fix this spacing so that it remain the same for both single line (short header text) and multiline (long header text) header text? Given that the solution to the header text and headrule has been found, I want to apply that fixed spacing used between headrule and header text to footrule and footer text as well. Below is my MWE:
% !TeX TS-program = pdflatex
\documentclass[12pt,openany,twoside]{book}
\raggedbottom
\usepackage[
left=2.5cm,
right=2.5cm,
top=3cm,
bottom=3cm,
headheight = 3.5\baselineskip,
headsep = 5mm,
a4paper
]{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\newcommand\HRule{\noindent\rule{\linewidth}{1.5pt}}
\usepackage{background}
\backgroundsetup{contents={}}
\usepackage{fancyhdr}
\usepackage{hhline}
\usepackage{helvet}
\usepackage{tabularx}%
\newcommand*\myheaderfooterfont{\sffamily\bfseries\selectfont}
\newlength{\leftspace}% for sections <<<<<<<<<
\setlength{\leftspace}{20ex}%set
\newlength{\Lheader}
\renewcommand{\chaptermark}[1]{\markboth{\uppercase{#1}}{}}%
\renewcommand{\sectionmark}[1]{\markright{\uppercase{#1}}}%
\fancypagestyle{fancy}{%
\fancyhf{}
\fancyhead[OL]{\myheaderfooterfont%
\ifnum\value{chapter}>0%
\begin{tabularx}{\textwidth}{@{}lX}\uppercase{Chapter~\thechapter}&\raggedright\leftmark\end{tabularx}% changed <<<<<<<<<<
\else\raggedright\leftmark\relax\fi}
\fancyhead[ER]{\myheaderfooterfont%
\settowidth{\Lheader}{\thesection\hspace*{12pt}\rightmark}
\ifnum\value{chapter}>0%
\ifdim\Lheader>\linewidth%
\begin{tabularx}{\dimexpr\textwidth-\leftspace}{@{}lX} \thesection &\raggedright\rightmark\end{tabularx}%
\else\begin{tabular}{@{}ll@{}} \thesection &\raggedright\rightmark\end{tabular}%
\fi\else\hfill\raggedright\rightmark\relax\fi
}% changed <<<<<
\fancyfoot{}
\fancyfoot[RE,RO]{\myheaderfooterfont\thepage}%last added<<<<<<<
%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<last added
\renewcommand\headrule
{{ \color{blue}\rule{0.33\headwidth}{2.5pt}% <---
\color{red}\rule{0.34\headwidth}{2.5pt}% <---
\color{orange}\rule{0.33\headwidth}{2.5pt}% <---
}}
%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<last added
}
\fancypagestyle{plain}{%
\fancyhf{}%
\renewcommand\headrule
{{ \color{blue}\rule{1\headwidth}{0pt}%
}}
\fancyfoot{}
\fancyfoot[RE,RO]{\myheaderfooterfont\thepage} %last added<<<<<<
}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{1pt}
\usepackage{showframe}
\usepackage[none]{hyphenat}
\raggedright % important with none hyphenat + none !!!!!!!!!!!!!!!!!
\begin{document}
%<<<<<<<<<<<<<<<<<<<<<<<<<last added
\begin{titlepage}
\setlength{\parindent}{0in}
\topskip 360pt
\vspace*{\fill}
\centering
\scshape
\begin{flushleft}
{ \textbf{HHHHHHHHHHHHHHHHHHHHHHHHGFFFFFFFFFFF}
}
\end{flushleft}
\vspace*{3\baselineskip}
\textbf{AUTHOR}
\vspace{0.5\baselineskip}
{\scshape\Large\selectfont LKJJHHHG}
\vspace{1.5\baselineskip}
\textbf{PFEYTYU}
\vspace{1\baselineskip}
{\scshape\Large\selectfont JKIU}
\vspace{2\baselineskip}
\textbf{YUUUUH}
\vspace{0.5\baselineskip}
{\scshape\Large\selectfont 12345}
\vspace{0.5\baselineskip}
\vfill
\vspace{4\baselineskip}
\scshape
Revised: \today
\end{titlepage}
%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<last added
\frontmatter
\chapter*{ABC}
\markboth{ABC1}{ABC2}
eeeheeyeyeyeyeyeeyeye
\section*{DEG}
dddheheheheheheheehehehe
\pagebreak
\section*{KJ}
ddhheheheheheehehehheheheheheh
\pagebreak
\section*{KDH}
dhddhhehehehehehehehehehehe
\mainmatter
\chapter{ABCD ffhfgrhr ejejejeje fhfhfhf ehehehehe dhddhdhellgl rkttkgkhihi eeeejejwnwn hhlhlnnmgjgj rjrrjoaoaoao }
eehehdhdhdhdddddd ddddddddddddddddddddd
\newpage
\section{Special keyboard characters gghthr rhrrhd fheheh fhehuw fhewiwi feiwiwd fiiwiwid fiiwiwi}
\LaTeX{} hasmany symbols at its disposal. The majority of them are within the mathematical domain as shown in \eqref{eq:1} and \eqref{eq:2}. The ten special keyboard characters are: \verb|#|, \verb|$|, \verb|%|, \verb|&|, \verb|~|, \verb|_|, \verb|^|, \verb|\| and \verb|{}|. If you simply want the character to be printed just as any other letter, include a \verb|\ | in front of the character. For example, \verb|\$| will produce \verb|$| in your output.
The exception to the rule is the \verb|\ | itself because \verb|\\ | has its own special meaning. A \verb|\ | is produced by typing \verb|$\backslash$| in your file.
\newpage
\section{Special keyboard characters}
Special keyboard characters dhgdgdg dgdgdgdg ggdgdgd egegegege dgddgdgd eggegegeg dgdgdgdgd egegegeg dggeieieirr tktii43iwje rfrhrhrhr gtktotyiyighgjgj fkf
\newpage
Special keyboard characters dhgdgdg dgdgdgdg ggdgdgd egegegege dgddgdgd eggegegeg dgdgdgdgd egegegeg dggeieieirr tktii43iwje rfrhrhrhr gtktotyiyighgjgj fkf
\chapter{One short line}
\LaTeX{} has many symbols at its disposal. The majority of them are within the mathematical domain as shown in \eqref{eq:1} and \eqref{eq:2}. The ten special keyboard characters are: \verb|#|, \verb|$|, \verb|%|, \verb|&|, \verb|~|, \verb|_|, \verb|^|, \verb|\| and \verb|{}|. If you simply want the character to be printed just as any other letter, include a \verb|\ | in front of the character. For example, \verb|\$| will produce \verb|$| in your output.
The exception to the rule is the \verb|\ | itself because \verb|\\ | has its own special meaning. A \verb|\ | is produced by typing \verb|$\backslash$| in your file.
\section{Special keyboard characters}
Special keyboard characters dhgdgdg dgdgdgdg ggdgdgd egegegege dgddgdgd eggegegeg dgdgdgdgd egegegeg dggeieieirr tktii43iwje rfrhrhrhr gtktotyiyighgjgj fkf
\newpage
Special keyboard characters dhgdgdg dgdgdgdg ggdgdgd egegegege dgddgdgd eggegegeg dgdgdgdgd egegegeg dggeieieirr tktii43iwje rfrhrhrhr gtktotyiyighgjgj fkf
\newpage
Special keyboard characters dhgdgdg dgdgdgdg ggdgdgd egegegege dgddgdgd eggegegeg dgdgdgdgd egegegeg dggeieieirr tktii43iwje rfrhrhrhr gtktotyiyighgjgj fkf
\end{document}
footer text
is the footer baseline or the footer top?