css audio


To add audio to a web page using CSS, you can use the audio element in HTML and then use CSS to style the element.

Here’s an example of how you might add an audio player to a web page using the audio element:

<audio controls>
    <source src="song.mp3" type="audio/mpeg">
    Your browser does not support the audio element.

This creates an audio player with controls (play, pause, etc.) that can be used to play the audio file song.mp3.

To style the audio player using CSS, you can use selectors to target specific elements and apply styles to them. For example:

audio {
    width: 300px;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    box-sizing: border-box;

audio::-webkit-media-controls-panel {
    background-color: #f2f2f2;

audio::-webkit-media-controls-mute-button {
    display: none;

audio::-webkit-media-controls-volume-slider {
    width: 100px;

This styles the audio player with a border, rounded corners, and padding, and changes the background color of the controls panel. It also hides the play and mute buttons and changes the width of the volume slider.