Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 4 123 ... LastLast
Results 1 to 15 of 57
  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How does one official escape tags, or what is otherwise known as code?

    Lets say i want to basically create a tutorial page, and on that page, i want to talk about specific pieces of code, or tags. How would i do that? In other words, if i want to talk about the table tags, i dont want the browser thinking that i am in fact trying to create a table.
    LovesWar

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Use &lt; for the <, and &gt; for the >

    Hope that helps. =)

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use &lt; for the <, and &gt; for the >

    Hope that helps. =)
    Not really. I will need an actual example.
    LovesWar

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Like this:
    Code:
    <p>Here's how to make a paragraph in HTML:</p>
    <pre><code>
    &lt;p&gt;Some text here&lt;/p&gt;
    </code></pre>
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    If you are using XML, you can use CDATA blocks as well. Inside them, everything will be treated as raw text. They begin with <[CDATA[ and end with ]]>. They are a feature of SGML, so theoretically they should be supported in HTML too, but sadly this is only in theory as real world browsers do typically not support CDATA blocks in HTML.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #6
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SpiritualStorms
    Lets say i want to basically create a tutorial page, and on that page, i want to talk about specific pieces of code, or tags. How would i do that? In other words, if i want to talk about the table tags, i dont want the browser thinking that i am in fact trying to create a table.
    & lt; table & gt; (remove spaces)
    If you don't want to convert all your code samples, you can use a php script which does the conversion on the fly -- making it far easier to update examples.
    I use david house's Wordpress plugin of Dunstan's code insertion script. This allows you to store you code samples as individual files in a folder structure of your choice as opposed to inserting the code in the page mark-up. The <ol> structure of the code stops it from screwing up a fixed width layout -- very handy

    Edit: lol.. when I pressed reply there were no responses. That's what you get for wandering off for an hour mid-post.
    Last edited by mindlessLemming; 10-23-2004 at 04:31 AM.

    I take no responsibility for the above nonsense.


    Left Justified

  • #7
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did some digging, and i got it now what you meant by this:

    from kurashu

    Use &lt; for the <, and &gt; for the >

    Hope that helps. =)
    from brothercake:

    <p>Here's how to make a paragraph in HTML:</p>
    <pre><code>
    &lt;p&gt;Some text here&lt;/p&gt;
    </code></pre>
    So if i wanted to include the less-than sign, ( i.e "<" ), i would basically escape it by literally typing "&lt;". Once i did that, i would then basically throw in the name of the tag i am interested in escaping. The third step would be to basically throw in the &gt; in order to have the greater-than sign, ( i.e ">" ).

    However before i do any of the above signs, i need to have the pre tags, correct?

    In essence then, all i am doing is escaping the greater-than, and less-than signs, nothing more.

    The above is what i am concluding from the following link:

    http://oregonstate.edu/instruct/cour.../hypertext.htm

    And the &amp is for spacing, correct?
    Last edited by SpiritualStorms; 10-23-2004 at 05:57 AM.
    LovesWar

  • #8
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You know, as i think about the above, i think a JavaScript function would be like absolutely awesome. What you think?

    Code:
    function escapingTagCode( param1 ){
    
    var start="&lt;"
    var end="gt;"
    var value="";
    
    if(param1){
    value=start+param1+end;
    }
    else
    { 
    alert("There is no parameter specified for this function.");
    }
    return value;
    }
    The above would be nice, but how then do you call it without a link, or a button acting as a trigger for the function?
    LovesWar

  • #9
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    &amp; makes the amperstand(&) symbol, and <pre>...</pre> is just preformatted text.

  • #10
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    from Kurashue:

    &amp; makes the amperstand(&) symbol, and <pre>...</pre> is just preformatted text.
    So i dont need them, then? And what is meant by <code> and </code>?
    LovesWar

  • #11
    Regular Coder
    Join Date
    Sep 2004
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey,
    I'm not sure if this will help or not but
    But I believe
    <code> and </code> make text appear like this
    Code:
    this is what happens when you have <code> and </code>
    . Hope this helps!

    I'm probably wrong because that only does that in this forum, not sure though!
    Last edited by Scootertaj; 10-23-2004 at 04:56 PM.

  • #12
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <pre> tags are preserved-formatting text That is, white space in a pre tag will not wrap. The only way to get a linebreak inside a pre tag is to use <br /> (or adjust the white-space via CSS)

    <code> tags will help you style the code examples in your CSS document. <pre> tags will preserve the formatting of large blocks of code. Inline code examples could just be wrapped in <code>.

  • #13
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Another way it could be done, may not be so nice though, but it would work.

    Just throw the example into a <textarea onfocus='this.blur();'><a href="http://yourURL.com">Yay</a></textarea>

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #14
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Although officialy deprecated and not recommended there always is the <XMP> tag...

    .....Willy

  • #15
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by AaronW
    <pre> tags are preserved-formatting text That is, white space in a pre tag will not wrap. The only way to get a linebreak inside a pre tag is to use <br />
    This is not quite correct. With <pre>, simply hitting the carriage return (enter button) will cause a line break. If <br /> is added, the lines in the preserved-formatted fixed-width text will be double spaced. White space in pre stays exactly as it is in the coding and does not require the use of &nbsp; to keep it there (unless of course, the wags at w3c have changed something so that <pre> suddenly acts differently)

    Here is a little page I wrote about using the <pre> tag for displaying ASCII-art:

    http://llizard.crosswinds.net/cwc/asciionpage.htm

    However, having said all that, if I were going to rewrite that page, I would now use the <code> tag for the coding examples as I did on the page I wrote about popup links


  •  
    Page 1 of 4 123 ... LastLast

    Posting Permissions

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