Rumah  >  Artikel  >  hujung hadapan web  >  Tag Audio HTML

Tag Audio HTML

WBOY
WBOYasal
2024-09-04 16:33:471145semak imbas

Teg audio HTML diperkenalkan dalam HTML 5. Teg ini digunakan untuk menambah semua fail audio pada halaman HTML. Teg audio ini juga menambah kawalan audio seperti main, kelantangan, jeda, dll. Dalam teg audio elemen digunakan untuk memilih fail audio alternatif yang dipilih oleh penyemak imbas, penyemak imbas sentiasa dipilih format yang diiktiraf pertama. Kami juga boleh menambah teks antara tag, tetapi ia tidak menjalankan fungsi audio; ia hanya bertindak sebagai teks biasa.

Pelayar dan format yang dibenarkan:

Browsers Formats
  MP3 WAV OGG
Edge/IE YES NO NO
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES
Pelayar

Format

 

MP3 WAV
File Format Media Type
MP3 audio/mpeg
OGG audio/ogg
WAV audio/wav

OGG

Tepi/IE

    YA
TIDAK TIDAK
  • Chrome YA
  • YA YA
  • Firefox YA
  • YA YA
  • Safari YA

    YA

    TIDAK

    Opera

    YA

    YA
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Audio Tag</title>
    <style type="text/css">
    h1
    {
    color: red;
    text-align: center;
    }
    p
    {
    color: green;
    font-size: 20px;
    border: 2px dotted brown;
    }
    </style>
    </head>
    <body>
    <h1>Audio Tag Introduction</h1>
    <p>HTML audio tag introduced in HTML 5. This tag is used to add all
    audio files to the HTML page. This audio tag also adds audio controls
    like play, volume, pause etc. In audio tag source element is used for
    choose alternative audio files which browser is choosing, browser is
    always choose first recognized format. We can also add text between
    audio and /audio tag but it is not performing audio functionality, it
    is just act as plain text.</p>
    <h1>MP3 Audio Demo from online source</h1>
    <audio controls>
    <source
    src="https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3"
    type="audio/mpeg">
    </audio>
    </body>
    </html>
    YA

    Bagaimanakah teg audio berfungsi dalam HTML? Audio HTML berfungsi berdasarkan jenis fail audio yang telah kami berikan dan atribut yang telah kami gunakan di dalamnya.

    Tag Audio HTML

    Format audio dan jenis media:

    Format Fail

    Jenis Media
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Audio Tag</title>
    <style type="text/css">
    h1
    {
    color: green;
    text-align: center;
    }
    p
    {
    color: blue;
    font-size: 20px;
    border: 2px solid orange;
    }
    </style>
    </head>
    <body>
    <h1>Audio Tag Introduction</h1>
    <p>HTML audio tag introduced in HTML 5. This tag is used to add all
    audio files to the HTML page. This audio tag also adds audio controls
    like play, volume, pause etc. In audio tag source element is used for
    choose alternative audio files which browser is choosing, browser is
    always choose first recognized format. We can also add text between
    audio and /audio tag but it is not performing audio functionality, it
    is just act as plain text.</p>
    <h1>WAV Audio Demo from online source</h1>
    <audio controls>
    <source
    src="https://file-examples.com/wp-content/uploads/2017/11/file_example_WAV_1MG.wav"
    type="audio/wav">
    </audio>
    </body>
    </html>
    MP3

    audio/mpeg
    OGG

    Tag Audio HTMLaudio/ogg

    WAV

    audio/wav

    Atribut
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Audio Tag</title>
    <style type="text/css">
    h1
    {
    color: blue;
    text-align: center;
    }
    p
    {
    color: fuchsia;
    font-size: 20px;
    border: 2px dashed red;
    }
    </style>
    </head>
    <body>
    <h1>Audio Tag Introduction</h1>
    <p>HTML audio tag introduced in HTML 5. This tag is used to add all
    audio files to the HTML page. This audio tag also adds audio controls
    like play, volume, pause etc. In audio tag source element is used for
    choose alternative audio files which browser is choosing, browser is
    always choose first recognized format. We can also add text between
    audio and /audio tag but it is not performing audio functionality, it
    is just act as plain text.</p>
    <h1>OGG Audio Demo from online source</h1>
    <audio controls autoplay>
    <source
    src="https://file-examples.com/wp-content/uploads/2017/11/file_example_OOG_5MG.ogg"
    type="audio/ogg">
    </audio>
    </body>
    </html>
    Ia adalah atribut yang berbeza dalam teg audio. Setiap atribut ini mempunyai fungsi mereka untuk dilaksanakan. Atribut yang dibenarkan dalam
    Kenyataan:
    Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
    Artikel sebelumnya:Alt Tag dalam HTMLArtikel seterusnya:Alt Tag dalam HTML