**Step 1: Simple [functions](/page/Function) are dense.** Let $f \in L^p(E)$ with $f \ge 0$ (the general case follows by decomposing into positive/negative and real/imaginary parts). By the [approximation of measurable functions by simple functions](/page/Lebesgue%20Integral), there exist simple functions $0 \le s_n \uparrow f$ pointwise. Since $0 \le |f - s_n|^p \le |f|^p$ and $|f - s_n|^p \to 0$ pointwise, the [Dominated Convergence Theorem](/theorems/511) gives $\|f - s_n\|_p \to 0$. Each $s_n \in L^p$ since $0 \le s_n \le f$ and $f \in L^p$.
**Step 2: $C_c^\infty(U)$ is dense in $L^p(U)$ for $U \subseteq \mathbb{R}^n$ open, $p < \infty$.** By Step 1 it suffices to approximate simple functions. By linearity it suffices to approximate $\mathbb{1}_A$ for $A \subseteq U$ Borel with $\mathcal{L}^n(A) < \infty$. By outer regularity of the Lebesgue measure, for any $\varepsilon > 0$ there is an [open set](/page/Open%20Set) $V$ with $A \subseteq V$ and $\mathcal{L}^n(V \setminus A) < \varepsilon$. By inner regularity there is a compact $K \subseteq A$ with $\mathcal{L}^n(A \setminus K) < \varepsilon$. A standard [mollification](/page/Standard%20Mollifier) argument produces $\phi \in C_c^\infty(U)$ with $0 \le \phi \le 1$, $\phi = 1$ on $K$, and $\operatorname{spt}(\phi) \subseteq V$. Then $\|\mathbb{1}_A - \phi\|_p^p \le \mathcal{L}^n(V \setminus K) < 2\varepsilon$.