Sunday, November 1, 2009

Inserting HTML tags

The problem with writing HTML, ASP etc. codes in your page is that the browser considers anything starting with an angle bracket as HTML code, it will try to make something of the code and hence your page will not be the way you intended it to be.

Let's say you are writing a tutorial for HTML and you want to convey to your readers how to make certain words appear bold in html. You'll naturally use the tag for bold... you'll try to use the tag, write some text within the opening and closing tags and try to show your users how the tag is used... instead, what you'll get will be the text appearing as bold and the tags used to make words appear bold absent.. this is because the browser considered the bold tag to be what it actually is.. the bold tag, it would think that you intended the text to appear in bold.. how is it supposed to know you are writing a tutorial anyways... (on second thought, if you are good enough to be writing HTML tutorials.. you would know this already)

What makes a tag, a tag are the surrounding angle brackets.. if you omit them anything you write won't be considered HTML or ASP tags.. the trick is to use the codes for the angle brackets...
The codes are as follows









<&lt;
>&gt;


So for the above example, you'll write something like..

<b>This is bold text.</b>

Refer to the following link for more codes..
http://codex.wordpress.org/Writing_Code_in_Your_Posts

8 comments:

Anonymous said...

Nice post, but if you searhed for this on the net u could have just asked. But its nice that u have posted it here, now it will serve as a future reference for both of us. So keep it up.

Haris Gulzar said...

Its been long since I wrote any code, so it felt good to read something related to programming, or more specifically, related to coding :-).

Intricate said...

@ammadsal
Thanks..
But I am guessing one of the few readers of my blog, already knew this.. so this post was a wastage of space? :P
Yup it has been put here so it can serve as a reference, if not for others than at least me.

Intricate said...

@Haris Gulzar..
Thanks :D

The Writer said...

I couldn't understand anything.. what was that all about :) :P

Intricate said...

@The Writer
hehe
You'll get it when you try to write a post on some code that includes tag for e.g. asp.net code in your post..
but you just reminded me that i have a blog.... and a life besides studying and job.. thanks :D
Let's just hope i remember that....

The Writer said...

:D I am reminding you a lot of things these days.. let's see how many you remember..

Intricate said...

@The Writer
Hein? You have? What were the others? :P