How can CSS sprites be implemented to optimize the performance of image-based navigation elements in PHP websites?

To optimize the performance of image-based navigation elements in PHP websites, CSS sprites can be used. CSS sprites combine multiple images into a single image, reducing the number of HTTP requests and improving loading times. This technique can be implemented by creating a sprite image that contains all the navigation element images and then using CSS to display only the relevant portion of the sprite for each navigation element.

<!DOCTYPE html>
<html>
<head>
    <style>
        .nav {
            background-image: url('sprites.png');
            background-repeat: no-repeat;
        }

        .home {
            width: 50px;
            height: 50px;
            background-position: 0 0;
        }

        .about {
            width: 50px;
            height: 50px;
            background-position: -50px 0;
        }

        .contact {
            width: 50px;
            height: 50px;
            background-position: -100px 0;
        }
    </style>
</head>
<body>
    <div class="nav home"></div>
    <div class="nav about"></div>
    <div class="nav contact"></div>
</body>
</html>