Many times you need to show up HTML or JavaScript or PHP codes in your posts, but you don't want them to execute. You just trying to show your users how to write the code. Then you need a tip so that the codes don't get executed, but show up as it is as texts. You can do it easily through pre tags. Anything you insert within a pre tag, it is displayed as it is as texts and not executed. Here is an example of using pre tags to show html codes.
Here the a tag is not executed, showing up the linked text only. You can see the actual code here. And the great thing is that it also keeps the formatting of the codes.
But one thing you have to remember while using the pre tag. You have to replace all the < with < and all the > with >. Otherwise you will not get the HTML codes shown up. So, now insert and show up as many codes as you want in your blog posts.
<body> <a href="acmeous.blogspot.com" title="Acmeous Blog of Web Technology" >Acmeous</a> </body>
Here the a tag is not executed, showing up the linked text only. You can see the actual code here. And the great thing is that it also keeps the formatting of the codes.
But one thing you have to remember while using the pre tag. You have to replace all the < with < and all the > with >. Otherwise you will not get the HTML codes shown up. So, now insert and show up as many codes as you want in your blog posts.
2 comments:
For inline code use <code> tags.
For new users, this will help them a lot. Thanks for sharing your knowledge.
Post a Comment