[Tex/LaTex] Right align header not working

fancyhdrheader-footer

I'm trying to align my header to the right side but it is not going all the way to the right.

enter image description here

Here is a minimal example (I'm including my margins in case that is part of the problem? I honestly have no idea):

\documentclass[11pt]{article}

\usepackage{blindtext}
\usepackage{nopageno}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\rhead{header}
\renewcommand{\headrulewidth}{0pt}

\textwidth=7in
\textheight=9.5in
\topmargin = -.25 in
\hoffset=-1in
\voffset=-0.5in
\parskip = 0.1in
\parindent = 0.0in

\begin{document}

\blindtext

\end{document}

Best Answer

You should set \pagestyle{fancy} after having set the page parameters, because fancyhdr uses the current text width for preparing its headers and footers.

I recommend using geometry, though: probably

\usepackage[textwidth=7in,textheight=9.5in]{geometry}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{header}
\renewcommand{\headrulewidth}{0pt}

is sufficient for your needs.

Above all, never set \hoffset and \voffset: they are thought for making corrections in case the output driver needs them.