HTML Music Code

From LoveToKnow Music

Many different HTML music codes have been used in order to ensure the sound file was played by all browsers. Before browsers were as sophisticated as they are now, inserting music into a webpage was difficult. Now, HTML music code is as simple as using one little tag!

adright

Step 1

Before you can insert the HTML music code, you have to have an audio file to link it to. If you have your own webspace and can upload files, simply copy the media onto your server. Otherwise you will need to ask someone with a web host who can share some space. Most free hosting plans don't allow music uploads, as the files tend to be very large.

Inserting HTML Music Code

When you're ready to insert the music code, use the tag. This simple tag allows you to point to the file you want to embed into the webpage that will load when your page loads.

Here's an example of the HTML music code using the tag:

<embed src="yoursound.mp3" />

This will load the file when the webpage loads and a simple media player will appear on your webpage where you placed this code.

If you aren't comfortable using relative paths in your filename, type use the full address of the file you are referring to.

The Look

Depending on the viewer's operating system and media software the tag will look different to everyone. You can change some of the attributes in order to have a little more control over its looks. Try setting the width and height like this:

<embed src="loremipsum.mid" width="240" height="100" />

Be careful with setting absolute dimensions, as the results could end up looking pretty strange. It's generally best to avoid using width and height commands in your music code unless you need to.

Loop and Volume

To get a little more fancy with your code, you can set the file to automatically start playing when the page loads, change the default volume level, and have the music loop. Here's an example:

<embed src="anothersong.ogg" autostart="true" loop="true" volume="40" />

This file would immediately begin playing when someone visits your page and it would loop until they click the stop button. Volume can be any number between 1 and 100, 100 being the loudest. Again, be careful setting these attributes, as you don't want to annoy your visitors with loud repeating music!

Other Options

Alternatively, if you simply want to link to a music file for someone to click and download, use the tag.

<a href="musicfile.mp3">text users will see</a>

This produces a plain text link that users can either download or just click on to open the music file. This is often the better choice for delivering sounds, as the file doesn't load until the user clicks on the link.

HTML Music Code Legalities

As always, don't upload and share music that is owned by someone else. Using sound clips from songs is generally fine, and freely-distributed sound files on websites such as MP3.com are also allowed. Don't share things you get from iTunes, as these aren't intended to be freely distributed.

Most .mid and .wav files are not owned by any individual or company and are free to be distributed. But as always, check with the author or website where you got the sounds to make sure!

With a little HTML know-how and some creativity, you can embed music files into your webpage for a stunning presentation. Entertain your visitors with your latest tunes and have your visitors dancing in their chairs!


 


Comments

music

-- Contributed by: Lori

I like your music a lot

-- Contributed by: Jessenia Saldana

Your music is really good and keep it up and one of the song i really like was "About Us".It makes me think of my boyfriend a lot.

-- Contributed by: Jessenia Saldana

Comment on HTML Music Code



(Displayed with your comment)                        (Will not be displayed)
Verification Code:   
    

Music

Sign up to get free email newsletters from LoveToKnow.



PRINT THIS PAGE

EMAIL TO FRIEND


You are here: LoveToKnow » Entertainment & Hobbies » Music » Myspace and Music Codes » HTML Music Code