# How to change the element color of the table in latex

How to change 2021-2022 to red color in the table

\documentclass{article}
\usepackage{tabularx}

\begin{document}
\begin{tabular}{cl}
Year 2023-2024 & Very long very long text Very long very long text Very long very long text  \\
Year 2022-2023 & Very long very long text Very long very long text Very long very long text \\
Year 2021-2022 & Very long very long text Very long very long text Very long   \\
Year 2020-2021 & Very long very long text Very long very long text Very long very long text  \\
Year 2019-2020 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
Year 2018-2019 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
\end{tabular}
\end{document}


You can use the \textcolor command in order to color the text. If you want to color the background of a cell, you can use the \cellcolor command as shown in the following MWE. I have also replaced the tabular by a tabularx environment (since you already loaded the tabularx package) in order to get rid of the overfull box:

\documentclass{article}
\usepackage[table]{xcolor} % <--- table option only needed if you want to color the background of a cell
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{\linewidth}{cX}
Year 2023-2024 & Very long very long text Very long very long text Very long very long text  \\
Year 2022-2023 & Very long very long text Very long very long text Very long very long text \\
\textcolor{red}{Year 2021-2022} & Very long very long text Very long very long text Very long   \\
\cellcolor{red} Year 2020-2021 & Very long very long text Very long very long text Very long very long text  \\
Year 2019-2020 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
Year 2018-2019 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
\end{tabularx}
\end{document}