Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set background music for html

Shulou Source: shulou.com Published: 2022-06-01 10:43:28 10月31日 Update

This article mainly introduces how to set background music html, has a certain reference value, interested friends can refer to, I hope you read this article after a great harvest, the following let Xiaobian take you to understand.

To set background music with html: first create a new web page, use the embed tag, and add src attribute to it; then add autostart attribute, the code is [autostart="true"].

Operating environment of this tutorial: Windows 7 system, HTML5 version, DELL G3 computer.

How to set background music with html:

First, we create a simple web page with only one DIV and a paragraph of text in the DIV. The code is as shown in the figure.

To add background music to a web page, we can use the embed tag and add the src attribute to it, which is used to specify the path of the music.

3. Because it is background music, this multimedia control needs to be hidden. Embed tag adds hidden hidden attribute. To make background music play automatically after opening the webpage, we can add autostart attribute.

4. By default, multimedia controls will only play once, and stop after playing. If your background music wants to play continuously, you can add the loopn attribute, loop="true".

Thank you for reading this article carefully. I hope that the article "html how to set background music" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Tags: Music background background music properties web pages articles tags code multimedia controls methods values interests content only at the same time tutorials text more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker Redmi Shulou Technology MySQL