HTML Link for a Container

HTML Link can also be applied over a container by including the container within the link element <a> as shown below.

In the below example, a block element <div> is used to create a container that included heading and paragraph elements as shown.

<a href="https://randomcodez.com">
    <div style="border: 2px solid orange; padding: 20px;">
        <h2>Random Codez</h2>
        <p>For Online Tutorials, Articles, Videos and many more..</p>
        <p>For Online Tools</p>
    </div>
</a>

Example

Check the outcome of the below HTML document to see how it looks.

<!doctype html>
<html lang="en">
<head>
</head>
<body>
    <h1>HTML Link over a Container</h1>
    <a href="https://randomcodez.com">
        <div style="border: 2px solid orange; padding: 20px;">
            <h2>Random Codez</h2>
            <p>For Online Tutorials, Articles, Videos and many more..</p>
            <p>For Online Tools</p>
        </div>
    </a>
</body>
</html>

Overall

HTML link can also be applied over a container by just including it inside a link element.

Related Articles