[Tex/LaTex] Square cell tabular, with centered content

cellcolumnstablestabularx

I'm trying to draw a tabular with all square cell.

This is my code:

\documentclass[a4paper,11pt,titlepage,oneside]{book}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{caption}

\begin{document}
    \begin{figure}
    \centering  
    \begin{tabular}{| >{\centering\arraybackslash}m{1cm} | >{\centering\arraybackslash}m{1cm} | >{\centering\arraybackslash}m{1cm} |}
    \hline
    \rule[1cm]{0pt}{0ex}A & B & C \\
    \hline
    \rule[1cm]{0pt}{0ex}D & \cellcolor[HTML]{333333} & \cellcolor[HTML]{333333}{\color[HTML]{333333} } \\
    \hline
    \rule[1cm]{0pt}{0ex}E & F & G \\
    \hline
    \end{tabular}
    \captionsetup{justification=centering,margin=1cm}
    \caption[Squares}
    \label{Squares}
    \end{figure}

\end{document}  

But the content is not centered inside the cell anymore.

enter image description here

Best Answer

enter image description here

\documentclass[a4paper,11pt,titlepage,oneside]{book}
\usepackage{array,booktabs}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage[table]{xcolor}

\begin{document}
\begin{figure}
    \centering
\setlength\tabcolsep{0pt}
\begin{tabular}{|@{\rule[-0.4cm]{0pt}{1cm}}*{3}{M{1cm} |}}
    \hline
A & B & C \\
    \hline
D & \cellcolor[HTML]{333333} & \cellcolor[HTML]{333333} \\
    \hline
E & F & G \\
    \hline
    \end{tabular}
\caption{Squares}
    \label{Squares}
    \end{figure}
\end{document} 
Related Question