Hello. I build a music gallery where users can click on various < audio > elements and listen to songs.
The problem is that many of the songs have an apostrophe in the song title and that is causing issues with the song not being recognized by the < audio > element or the song title not rendering correctly in my HTML.
Is there an easy way to make it so my browser doesn’t misinterpret the HTML when it comes across an apostrophe?
As you can see, there are 3 places where an apostrophe can break my HTML, and that is what I need help with - because to the end user, that apostrophe makes things proper English!
Actually it is the apostrophes, because all of my songs have spaces and hypens in them and the web page loads okay and the music plays okay with them.
For example…
<ul>
<li>
<span>Zombies - Time Of The Season</span>
<audio class=audioPlayer2" controls loop title="Zombies - Time Of The Season">
<source src="/client1/audio/Zombies - Time Of The Season.mp3">
</audio>
</li>
</ul>
Since my IDE is on my Mac, I do my primary development on macOS with FireFox 71.0 and then Chrome 72.0
When I post code simple samples here (e.g. just HTML/CSS) I do so using my notebook with Windows 10 and Chrome.
Either way, what can I do to improve things so my songs play on all OS’s and all browsers?
It sounds like spaces, hyphens and apostrophes trip up different browsers and OS’s?
It would be a pain in the ass to have to change all of my songs to “Zombies_TimeOfThSeason.mp3” and even worse if I cannot have the HTML titles/labels be properly formatted English.
That being said, we must be missing something here, because any modern OS I have seen will take any characters and spaces in filenames…
But is it a problem to have spaces, hyphens and apostrophes in a file name?
Can you please explain how I would do that?
Fwiw, sometimes I intermingle HTML and PHP which is common, but in this particular case I am using straight up HTML, so I don’t thin that would help.
So that comes back to my OP in asking what HTML or the browsers don’t like about an apostrophe in my HTML, e.g. title=“Journey - Who’s Crying Now” or < source src=“Journey - Who’s Crying Now” type=“mpeg/audio” >
What PHP outputs is just HTML, so yes you can do it manually in HTML, it’s just PHP will automate the encoding.
To do it manually see my initial reply.
%hex code for URLs, HTML Number or Name for general HTML.
First off, there is no apostrophe listed in that link.
If I used a single quote, then I would add & # 39 ; in my HTML wherever I wanted a single quote and then that wouldn’t break things like the < audio > tag?
It may break, because you put unwanted spaces in it.
Written properly, without the spaces it will appear on the page as a single quote, but as far as the code is concerned, it is not one. So you can have:-