Recent advances in nanofabrication methods have made it possible to create complex two-dimensional artificial structures, such as fractals, where electrons can be confined. The optoelectronic and plasmonic properties of these exotic quantum electron systems are largely unexplored. In this article, we calculate the optical conductivity of a two-dimensional electron gas in a Sierpinski carpet (SC). The SC is a paradigmatic fractal that can be fabricated in a planar solid-state matrix by means of an iterative procedure. We show that the optical conductivity as a function of frequency (i.e. the optical spectrum) converges, at finite temperature, as a function of the fractal iteration. The calculated optical spectrum features sharp peaks at frequencies determined by the smallest geometric details at a given fractal iteration. Each peak is due to excitations within sets of electronic state-pairs, whose wave functions are characterized by quantum confinement in the SC at specific length scales, related to the frequency of the peak.