mohansinfh — 2010-12-19T07:22:54-05:00 — #1
Hi, I have a little question on HTML,
Today I experimented 1 thing,
I wrote this in HTML, (without spaces)
&# 100 ; &# 115; &# 32;
which prints ds on the screen.
Is there any way that in the ds will be printed in the source code as well (by some method), because in the source code, &# 100 ; &# 115; &# 32; are displaying, which seems rubbish?
stevie_d — 2010-12-19T07:33:15-05:00 — #2
The source code is the source code. What you see when you go to a page and click 'view source' is what the browser has downloaded, and that will be the same for any browser or bot. The key is that a browser will interpret those entities as particular characters and display those characters instead of the entities, just as it will interpret ½ as ½.
The most useful application of this is to use @ instead of @ when putting email addresses or mailto links on a site - they still look and behave the same, but not many bots will bother to interpret @ as @ so they won't recognise it as an email address, so you won't get as much spam.
When you're starting a new topic, it would be helpful if you could use a subject title that gives a bit more clue what it's about. If you put a title like "HTML character entities", that will make it much easier for someone else to decide whether they're interested in reading it than "A little question in HTML", which could cover just about any topic on this forum! Thanks
xhtmlcoder — 2010-12-19T08:58:07-05:00 — #3
The source code is designed to show what was written (like Stevie said).
So it would be rather pointless if the browser started thinking it were humours changing; Character entity references and Numeric Character References in the source – let alone the fact they would probably cease to function.
Now, if you wanted to avoid having to enter certain entities you may want to save as UTF-8 so you could input the special character directly.
chroniclemaster1 — 2010-12-21T01:31:34-05:00 — #4
I use UTF-8 exclusively, and this turns out to be really simple. You input the entities you need which outputs the characters which you would otherwise have difficulty typing on your keyboard. These output as the actual characters in the browser. You then copy the actual characters from the browser and paste them into your source code. This in turn makes your source code readable, because otherwise... you're absolutely right, your source code is rubbish.
I work in .NET and C# actually makes this even easier. You can enter any Unicode character using the convention "\u" followed by the four digit hexcode, e.g.
outputTestInput += "\\u00c2";
outputTestInput += "\\u00c3";
Appending these strings to the output adds a capital letter A with circumflex accent, Â, and capital letter A with tilde accent, Ã. This was how I generated a list of extended latin and non-latin characters for some test input. This was a quick way to generate a block of 16 non-standard keyboard characters in about 16 seconds and then paste the results back into the source code and create another block of characters.
stomme_poes — 2010-12-21T04:01:39-05:00 — #5
chroniclemaster1 — 2010-12-22T22:55:40-05:00 — #6
Better you than me though. I'd be hopeless.
stomme_poes — 2010-12-23T05:06:34-05:00 — #7
Better you than me though. I'd be hopeless
Write a crapload of mailto:email@example.com/.nl
and you'll be amazed.