\documentclass{article}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\tikzstyle{every node}=[font=\footnotesize]
\node[anchor=north west, inner sep=0, rectangle, red, draw, minimum width=0.5cm](A) {%
\begin{minipage}[t]{0.5cm}%
x\\
x
\end{minipage}};
\node[inner sep=0, rectangle, blue, draw, minimum width=0.5cm, anchor=north west](B) at (0.5cm, -\baselineskip) {%
\begin{minipage}[t]{0.5cm}%
x\\
x
\end{minipage}};
\end{tikzpicture}
\end{document}

How can I align the two rectangles that it looks like...

You get this result if \tikzstyle{every node}=[font=\footnotesize] is commented out. The problem is that I need a smaller font size. I have tried to set the shift to -\footnotesep but no success.

\baselineskipunder\footnotesizeis 9.5pt; see{\footnotesize\the\baselineskip}. – Werner Jan 08 '14 at 07:00\\but rather a tikz question of how to propagate alignment from inner boxes to the outer node. The alignment you want is automatic with\begin{minipage}[b]{5mm}...\end{minipage}\begin{minipage}[t]{5mm}...\end{minipage}so your question is not about\\and\baselineskipbut about how to add the tikz boxes without breaking alignment. (Also it should not be tagged pdftex as you see same with classic tex or xetex or luatex) – David Carlisle Jan 08 '14 at 09:50\setlength{\mylength}{9.5pt}would work. :) But you can also try{\footnotesize\global\setlength{\mylength}{\baselineskip}}. – Werner Jan 09 '14 at 15:49