\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage{tikz}
\usetikzlibrary{shapes, decorations}
\usepackage{amsmath,amssymb}

\begin{document}
\begin{preview}


% Define box and box title style
\tikzstyle{mybox} = [
    draw=red,
    fill=blue!20,
    very thick,
    rectangle,
    rounded corners,
    inner sep=10pt,
    inner ysep=20pt
]
\tikzstyle{fancytitle} =[fill=red, text=white]


\begin{tikzpicture}
    \node [mybox] (box){
        \begin{minipage}{0.9\textwidth}
            $\underbrace{\text{http}}_{\text{protocol}}
            \text{://}
            \underbrace{
                \overbrace{\text{martin-thoma}}^\text{2\textsuperscript{nd} level domain}
                \text{.}
                \overbrace{\text{com}}^\text{TLD}
            }_\text{hostname}
            \underbrace{\text{/why-to-study-math/}}_\text{path}
            \text{\#}
            \underbrace{\text{Math\_is\_fun}}_\text{Fragment identifier}$
        \end{minipage}
    };
    \node[fancytitle, right=10pt] at (box.north west) {The URL};
\end{tikzpicture}

\end{preview}
\end{document}
