SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2010
    Location
    ONS
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A little question in HTML

    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?

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mohansinfh View Post
    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?
    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.

    Off Topic:

    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

  3. #3
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mohansinfh View Post
    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?
    Quote Originally Posted by xhtmlcoder View Post
    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.
    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.
    Whatever you can do or dream you can, begin it.
    Boldness has genius, power and magic in it. Begin it now.

    Chroniclemaster1, Founder of Earth Chronicle
    A Growing History of our Planet, by our Planet, for our Planet.

  5. #5
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    I just leave them as entities. It's gotten to the point that I can now read most of the letters in my email addresses and chars like @ and . : ) But I didn't recognise the ones above... because they're decimal. If you use hex then you don't have to remember another set of numbers for Javascript or anything.

  6. #6
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    I just leave them as entities. It's gotten to the point that I can now read most of the letters in my email addresses and chars like @ and . : )
    :O Wow!

    Better you than me though. I'd be hopeless.
    Whatever you can do or dream you can, begin it.
    Boldness has genius, power and magic in it. Begin it now.

    Chroniclemaster1, Founder of Earth Chronicle
    A Growing History of our Planet, by our Planet, for our Planet.

  7. #7
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    Better you than me though. I'd be hopeless
    Write a crapload of mailto:subject=something@somecompany.com/.nl
    and you'll be amazed.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •