Table formatting: remove horizontal and vertical borders from only specific cells

Like this?

screenshot of table

You have many possibilities, one of them is use \multicolumn command which hasn't border lines:

\newcommand\mcc[1]{\multicolumn{1}{c}{#1}} % <--- 

\author{Algebra Teacher Who Struggles with LaTeX Tables}
\date{January 2021}


In the table below, I only want \textbf{borderlines around the values in black,
} not the red values above and to the left of the black colored values.

Also, I can't figure out a way to \textbf{remove the gray shading from upper left corner cell.}

\begin{tabular}{ c | c | c | }
 %  \hline
 \mcc{} & \mcc{\textcolor{red}{$x$}} & \mcc{\textcolor{red}{$+6$}} \\
 \textcolor{red}{$x$} & $x^2$ & $6x$ \\
 \textcolor{red}{$+2$} & $2x$ & $12$ \\



Another possibilities is to use ˙blkarray package:


\begin{blockarray}{r cc}
    & \textcolor{red}{x} & \textcolor{red}{+6}   \\
\textcolor{red}{x} & x^2 & 6x \\
\textcolor{red}{+2} & 2x & 12 \\

Result is the same as before.

With the package nicematrix.



    first-row, code-for-first-row = \color{red},
    first-col, code-for-first-col = \color{red}
   & x   & +6 \\
x  & x^2 & 6x \\
+2 & 2x  & 12


You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code