One more answer ...
As said @Ignasi in his answer, only nodes has anchors. You can predefine node shapes with option of its width and height, which you determined when use it. Text in it is centered, their starting coordinate can be defined as in above MWE with help of tikzlibrary `positioning:
\documentclass[border=3mm,tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
node distance=0mm,
box/.style args = {#1/#2}{shape=rectangle,
text width=#1mm, minimum height=#2mm,
draw, thick, inner sep=0pt, outer sep=0pt,
align=center, text=black}
]
\draw[thin, gray!25] (0,0) grid (8,8);
%
\node[box=20/10,blue,above right=of {(0,1)}] (a) {my text};%
\node[box=30/40,red, above right=of {(5,4)}] (b) {my very very very very long text}; %
%
\draw[thick, red] (a) -- (b);
\draw[thick, blue] (a) |- (b);
\draw[thick, green] (a.north east) -- (b.south west);
%
\draw[<-] (b.south west) -- + (0,-1) node[below] {coordinate (5,4)};
\draw[very thin,densely dashed] (a.center) -- (b.center);
\end{tikzpicture}
\end{document}
or directly:
\documentclass[border=3mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[
node distance=0mm,
box/.style args = {#1/#2}{shape=rectangle,
text width=#1mm, minimum height=#2mm,
draw, thick, inner sep=0pt, outer sep=0pt,
above right, align=center, text=black}
]
\draw[thin, gray!25] (0,0) grid (8,8);
%
\node[box=20/10,blue] (a) at (0,1) {my text};%
\node[box=30/40,red ] (b) at (5,4) {my very very very very long text}; %
%
\draw[thick, red] (a) -- (b);
\draw[thick, blue] (a) |- (b);
\draw[thick, green] (a.north east) -- (b.south west);
%
\draw[<-] (b.south west) -- + (0,-1) node[below] {coordinate (5,4)};
\draw[very thin,densely dashed] (a.center) -- (b.center);
\end{tikzpicture}
\end{document}
In both cases we get the same result:
