[latex] latex tabular width the same as the textwidth

I am generating some table as follow:

\begin{tabular}[l]{|l|l|l|}
\hline
Input & Output& Action return \\
\hline
\hline
DNF &  simulation & jsp\\
\hline

\end{tabular}

How can can I give this table the same width as the text width? For graphic I use

[width=\textwidth]

But this doesn't work for table.

This question is related to latex

The answer is


The tabularx package gives you

  1. the total width as a first parameter, and
  2. a new column type X, all X columns will grow to fill up the total width.

For your example:

\usepackage{tabularx}
% ...    
\begin{document}
% ...

\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
Input & Output& Action return \\
\hline
\hline
DNF &  simulation & jsp\\
\hline
\end{tabularx}