How to automatically play music when opening HTML web pages?

Discussion in 'HTML & Website Design' started by Strength, Sep 27, 2021.

  1. #1
    Recently, I want to make a small web page. How to click on it to automatically play music?
     
    Strength, Sep 27, 2021 IP
  2. shalom_m

    shalom_m Member

    Messages:
    49
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    33
    #2
    Use these lines below

    <audio controls autoplay>
    <source src="path/your-music.ogg" type="audio/ogg">
    <source src="path/your-music.mp3" type="audio/mpeg">
    </audio>

    If you don’t want it to start playing automatically, delete “autoplay” in the first line.
     
    shalom_m, Nov 19, 2021 IP