{"id":202,"date":"2012-04-21T21:42:51","date_gmt":"2012-04-21T13:42:51","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=202"},"modified":"2018-09-03T22:04:53","modified_gmt":"2018-09-03T14:04:53","slug":"code-segments-for-rendering-html-4-0-pages","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/code-segments-for-rendering-html-4-0-pages\/","title":{"rendered":"Code segments for rendering html 4.0 pages"},"content":{"rendered":"<p>Very often, I find myself creating HTMl pages from scratch. Those could have been situations when I want to try out some javascripts or write some php proof of concepts. <\/p>\n<p>Although there are many frameworks around, I still prefer the pristine way of rendering HTML pages as I can be certain that there will not be conflicting javascripts or php scripts when I need to try something out.<\/p>\n<p>In this post, I put together pieces of HTML codes that I find myself using often. This will make HTML development more convenient as I do not have to wade through the many search results from google to look for them.<\/p>\n<h3>Skeletal HTML codes to render a webpage<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN&quot; \r\n    &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd&quot;&gt;\r\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;&lt;!-- Insert your title here --&gt;&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;!-- Insert your content here --&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3>Meta information<\/h3>\n<h4>HTML codes for including external stylesheet<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;link rel=&quot;stylesheet&quot; href=&quot;external.css&quot; type=&quot;text\/css&quot; media=&quot;all&quot;\/&gt;\r\n<\/pre>\n<h4>HTML codes for including internal stylesheet<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\nbody {\r\n    margin:0;\r\n    padding:0;\r\n}\r\n#mainContent {\r\n    width: 1024px;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<p><strong>Note that we use the <code>link<\/code> tag to specify external style sheets but we use the <code>style<\/code> tag to specify internal ones. <\/strong><\/p>\n<h4>HTML codes for including external javascript<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;external.js&quot;&gt;&lt;\/script&gt;\r\n<\/pre>\n<h4>HTML codes for including internal javascript<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n    alert('Internal javascript.');\r\n&lt;\/script&gt;\r\n<\/pre>\n<h4>HTML codes for including apple touch icon<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;link rel=&quot;apple-touch-icon&quot; href=&quot;http:\/\/www.techcoil.com\/img\/appletouchicon.png&quot;&gt;\r\n<\/pre>\n<h4>HTML codes for specifying view ports of mobile browers<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;meta name=&quot;viewport&quot; content=&quot;width=1024&quot;&gt;\r\n<\/pre>\n<p>This meta tag is used to prevent mobile browsers from setting the wrong dimensions when displaying your webpage. In this example, I specify the width of the viewport to be 1024 pixels so that my webpage do not look like this:<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/ph\/img\/blog\/posts\/techcoil-v1-with-default-viewport.jpg\"\/><\/p>\n<p>Without the meta tag, the container that fills the sky color was being shrunk to the default view port size of my mobile browser. However, the overall content width is much larger than that, which reveals the background color of the body container.<\/p>\n<p>After indicating the view port size, my webpage rendered according to what I had intially wanted:<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/ph\/img\/blog\/posts\/techcoil-v1-with-custom-viewport.jpg\"\/> <\/p>\n<h3>HTML body (forms)<\/h3>\n<h4>Forms<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!--\r\nBrowser will take the input from the fields \r\nand do a HTTP post to httpPostHandler.php\r\n--&gt;\r\n&lt;form method=&quot;post&quot; action=&quot;httpPostHandler.php&quot;&gt;\r\n&lt;fieldset&gt;\r\n    &lt;label for=&quot;nameTextField&quot;&gt;Name:&lt;\/label&gt;\r\n    &lt;input name=&quot;nameTextField&quot; type=&quot;text&quot;\/&gt;\r\n&lt;\/fieldset&gt;\r\n&lt;!--More form elements...--&gt;\r\n&lt;fieldset&gt;\r\n        &lt;input name=&quot;submitButton&quot; type=&quot;submit&quot; value=&quot;submit&quot;\/&gt;\r\n&lt;\/fieldset&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;!--\r\nBrowser will take the input from the fields \r\nand do a HTTP get to httpGetHandler.php\r\n--&gt;\r\n&lt;form method=&quot;get&quot; action=&quot;httpGetHandler.php&quot;&gt;\r\n&lt;fieldset&gt;\r\n    &lt;label for=&quot;nameTextField&quot;&gt;Name:&lt;\/label&gt;\r\n    &lt;input name=&quot;nameTextField&quot; type=&quot;text&quot;\/&gt;\r\n&lt;\/fieldset&gt;\r\n&lt;!--More form elements...--&gt;\r\n&lt;fieldset&gt;\r\n        &lt;input name=&quot;submitButton&quot; type=&quot;submit&quot; value=&quot;submit&quot;\/&gt;\r\n&lt;\/fieldset&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<h4>Drop down \/ selection lists<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!--\r\nSingle selection drop down list\r\nBrowser will send the value in the \r\nvalue attribute to the server script\r\nwhen the form is submitted.\r\n--&gt;\r\n&lt;select name=&quot;fruitsList&quot;&gt;\r\n    &lt;option value=&quot;noSelection&quot;&gt;Please select one&lt;\/option&gt;\r\n    &lt;option value=&quot;apple&quot;&gt;Apple&lt;\/option&gt;\r\n    &lt;option value=&quot;guava&quot;&gt;Guava&lt;\/option&gt;\r\n    &lt;option value=&quot;orange&quot;&gt;Orange&lt;\/option&gt;\r\n    &lt;option value=&quot;watermelon&quot;&gt;Watermelon&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n\r\n&lt;!--\r\nMutiple selection drop down list\r\nBrowser will send the value(s) in the \r\nvalue attribute to the server script\r\nwhen the form is submitted.\r\n--&gt;\r\n&lt;select name=&quot;fruitsList&#x5B;]&quot; multiple=&quot;multiple&quot;&gt;\r\n    &lt;option value=&quot;apple&quot;&gt;Apple&lt;\/option&gt;\r\n    &lt;option value=&quot;guava&quot;&gt;Guava&lt;\/option&gt;\r\n    &lt;option value=&quot;orange&quot;&gt;Orange&lt;\/option&gt;\r\n    &lt;option value=&quot;watermelon&quot;&gt;Watermelon&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n<\/pre>\n<p><strong>Note that the square brackets are included after the name of the multiple selection list so that the PHP script can read the selected values as an array, instead of as a single value.<\/strong><\/p>\n<h4>Textfield<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input name=&quot;nameTextField&quot; type=&quot;text&quot; size=&quot;30&quot; maxlength=&quot;50&quot;\/&gt;\r\n<\/pre>\n<h4>Textarea<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;textarea name=&quot;aboutYourselfTextArea&quot; cols=&quot;30&quot; rows=&quot;20&quot;&gt;Some initial values.&lt;\/textarea&gt;\r\n<\/pre>\n<h4>Checkbox<\/p>\n<h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;checkbox&quot; name=&quot;lovesToCodeCheckbox&quot; value=&quot;yes&quot;\/&gt;I love to code\r\n<\/pre>\n<h4>HTML codes for radio button<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;Male&quot;\/&gt;Male\r\n&lt;input type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;Female&quot;\/&gt;Female\r\n<\/pre>\n<p><strong>Note that the name is the same for each radio button that you wish to group together. <\/strong><\/p>\n<h4>Hidden fields<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;hidden&quot; name=&quot;sessionId&quot; value=&quot;ABCD1234&quot;\/&gt;\r\n<\/pre>\n<h4>Form submission button<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input name=&quot;submitButton&quot; type=&quot;submit&quot; value=&quot;Name of the button&quot;\/&gt;\r\n<\/pre>\n<p>Note that the <strong>display name<\/strong> of the button is indicated by the <code>value<\/code> attribute and <strong>not by<\/strong> the <code>name<\/code> attribute. <\/p>\n<h3>HTML body (data representation)<\/h3>\n<h4>Table<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;table&gt;\r\n&lt;tr&gt;\r\n    &lt;th&gt;Fruit&lt;\/th&gt;\r\n    &lt;th&gt;Color&lt;\/th&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n    &lt;td&gt;Apple&lt;\/td&gt;\r\n    &lt;td&gt;Red&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n    &lt;td&gt;Kiwi&lt;\/td&gt;\r\n    &lt;td&gt;Green&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n    &lt;td&gt;Orange&lt;\/td&gt;\r\n    &lt;td&gt;Orange&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n<\/pre>\n<h4>Numbered \/ ordered list<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;ol&gt;\r\n    &lt;li&gt;Create skeleton of HTML page.&lt;\/li&gt;\r\n    &lt;li&gt;Fill in visual elements.&lt;\/li&gt;\r\n    &lt;li&gt;Add in CSS style to style the visual elements.&lt;\/li&gt;\r\n&lt;\/ol&gt;\r\n<\/pre>\n<h4>Bullet-ed \/ unordered list<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;ul&gt;\r\n    &lt;li&gt;Apple&lt;\/li&gt;\r\n    &lt;li&gt;Orange&lt;\/li&gt;\r\n    &lt;li&gt;Pear&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<h4>Hyperlink<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;a href=&quot;http:\/\/www.techcoil.com&quot; title=&quot;The home page of techcoil.com&quot; target=&quot;_blank&quot;&gt;\r\n    My homepage\r\n&lt;\/a&gt;\r\n<\/pre>\n<h4>Paragraphs<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;p&gt;\r\nThe HTML codes for paragraphs is one of the most intuitive for me.\r\n&lt;\/p&gt;\r\n&lt;p&gt;\r\nBut that may not be the case for everyone. \r\nI guess I shall include HTML codes for rendering paragraphs as well. \r\n&lt;\/p&gt;\r\n<\/pre>\n<h4>Image<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;img src=&quot;http:\/\/www.techcoil.com\/logo.png&quot; alt=&quot;My logo&quot;\/&gt;\r\n<\/pre>\n<h4>Custom click-able points on an image<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;img src=&quot;planets.gif&quot; width=&quot;145&quot; height=&quot;126&quot; alt=&quot;Planets&quot; usemap=&quot;#planetmap&quot; \/&gt;\r\n\r\n&lt;map name=&quot;planetmap&quot;&gt;\r\n  &lt;area shape=&quot;rect&quot; coords=&quot;0,0,82,126&quot; href=&quot;sun.htm&quot; alt=&quot;Sun&quot; \/&gt;\r\n  &lt;area shape=&quot;circle&quot; coords=&quot;90,58,3&quot; href=&quot;mercury.htm&quot; alt=&quot;Mercury&quot; \/&gt;\r\n  &lt;area shape=&quot;circle&quot; coords=&quot;124,58,8&quot; href=&quot;venus.htm&quot; alt=&quot;Venus&quot; \/&gt;\r\n&lt;\/map&gt;\r\n<\/pre>\n<h3>References<\/h3>\n<p>This post is for people to copy and paste HTML codes easily and does not delve deep into HTML. If you need to learn more about HTML, you can visit <a href=\"http:\/\/www.w3schools.com\/html\/default.asp\" title=\"Link to HTML tutorial @ w3schools.com\" target=\"_blank\">w3schools<\/a>. If you prefer books, I strongly recommend the following book:<\/p>\n<p><a href=\"http:\/\/www.amazon.com\/gp\/product\/0987090852\/ref=as_li_ss_tl?ie=UTF8&tag=clivsperswebs-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0987090852\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/ph\/img\/recommended-books\/build-your-website-the-right-way-using-html-and-css-big.jpg\"\/><\/a><\/p>\n<h3>Related posts<\/h3>\n<ul>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/quick-references\/how-to-validate-input-fields-as-the-user-is-filling-up-a-form-with-jquery\/\" title=\"How to validate input fields as the user is filling up a form with jQuery\" target=\"_blank\">How to validate input fields as the user is filling up a form with jQuery<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/book-reviews\/some-resources-that-i-referenced-for-producing-things-on-the-web\/\" title=\"Some resources that I reference(d) for producing things on the web\" target=\"_blank\">Some resources that I reference(d) for producing things on the web<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/quick-references\/generate-php-codes-with-php\/\" title=\"Generate PHP codes with PHP\" target=\"_blank\">Generate PHP codes with PHP<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/quick-references\/downloading-a-file-from-via-http-post-and-http-get-in-c\/\" title=\"Downloading a file via HTTP post and HTTP get in C#\" target=\"_blank\">How to download a file via HTTP post and HTTP get in C#<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/quick-references\/a-mechanism-for-serving-http-requests-in-c\/\" title=\"A mechanism for to serve HTTP requests in C#\" target=\"_blank\">How to build a web server serving HTTP request with C#<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/how-to-ensure-that-your-javascript-is-able-to-write-unicode-characters-from-external-javascript-files-to-your-html-contents\/\" title=\"How to ensure that your Javascript is able to write unicode characters from external Javascript files to your HTML contents\" target=\"_blank\">How to ensure that your Javascript is able to write unicode characters from external Javascript files to your HTML contents<\/a><\/li>\n<\/ul>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-3g\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-3g&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-3g&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F202&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>Very often, I find myself creating HTMl pages from scratch. Those could have been situations when I want to try out some javascripts or write some php proof of concepts. <\/p>\n<p>Although there are many frameworks around, I still prefer the pristine way of rendering HTML pages as I can be certain that there will not be conflicting javascripts or php scripts when I need to try something out.<\/p>\n<p>In this post, I put together pieces of HTML codes that I find myself using often. This will make HTML development more convenient as I do not have to wade through the many search results from google to look for them.<\/p>\n","protected":false},"author":1,"featured_media":1212,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[375],"tags":[117,16],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/HTML-file-extension-logo.gif","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-3g","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/202"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=202"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/202\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1212"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}