Skip to content

How to create a simple website using HTML and CSS that plays an MP3 file as background music

Notifications You must be signed in to change notification settings

natrixdev/html-background-music

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

html-background-music

How to create a simple website using HTML and CSS that plays an MP3 file as background music

In this example, we're using the background-image CSS property to set the background image of the webpage to background-image.jpg, which should be located in the same directory as the HTML file. We're also setting the font family and text color of the body to white.

Next, we're using the audio HTML element to embed an MP3 file (music.mp3) as background music. We've set the loop attribute to make the audio repeat, and autoplay attribute to make the audio start playing automatically when the page loads. We've also hidden the audio element using CSS (display: none;) so that it doesn't take up any space on the page.

Finally, we're adding some sample text to the page using h1 and p elements.

Note: It's generally not recommended to use HTML and CSS in the same file. It's better to separate them into different files to improve readability and maintainability.

About

How to create a simple website using HTML and CSS that plays an MP3 file as background music

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages