Skip to main content

Posts

Showing posts with the label HTML

Using PX With Image Height And Width

 Try validating below HTML codes in https://validator.w3.org/#validate_by_input. <!DOCTYPE html> <html> <head> <title>hello</title> </head> <body> <img src="238364.jpeg" width="100px" height="100px" alt="public image"> </body> </html> After validating you may find the below message: Error: Bad value 100px for attribute width on element img: Expected a digit but saw p instead . And when your remove px for height and width from above example you find NO ERROR or WARNING message. So just write height and width in digits only, px is predetermined so no need to mention it with digits.

HTML Coding Standard

 After understanding coding standard of CSS from wordpress.org, I looked for coding standard for HTML and found below two useful links: https://make.wordpress.org/core/handbook/best-practices/coding-standards/html/ http://developer.fellowshipone.com/patterns/code.php I'm making HTML coding standard from the above links in my own terms. They may be exactly the same, or with some changes that I like. Here we go: Indentation Like CSS coding standard, use tab/s not spaces. Opening and Closing block should have same indentation; whatever falls in between should indent to the right. Case Use lowercase for elements, tags and attributes. Quotes for security (with strictness of XHTML) I read, "failing to quote attributes can lead to security vulnerabilities," so better not to compromise with security. Use quotes for a value. I prefer double quotes. Example: <input type="text" name="email" disabled="disabled" /> Self closing elements (prefer stri...

One Page HTML

 I tried to write HTML in a single page, I hope it will help in understanding HTML quickly. ============================== <!doctype> element: it stands for document type. It should be declared at the very beginning of HTML source code. Example: <!doctype html> ============================== HTML is case-insensitive language, you could write <!DOCTYPE HTML> as well, but it is always good to stick with one writing style. ============================== Root element <html>: after <!doctype> declaration is made, the root element starts; and everything comes in between opening and closing of root element. Example: <!doctpe html> <html> ... </html> ============================== Attribute "lang": "lang" stands for language, it is declared in root element. Example: <!doctype html> <html lang="en"> ... </html> ============================== <head> element: after root element, <head> elem...

HTML Element -- SPAN

 After <div> element, <span> element is most loved inline element. It could be used anywhere in a text, and we can use INLINE CSS STYLE, CLASS or ID with it. Example of INLINE CSS STYLE: <p>This is <span style="color:orange">orange color.</span></p> Example of using using CLASS: <p>This is <span class="orange">orange color.</span></p> Example of using ID:

HTML Element - Form

 Using form we receive data from the user. Without using form, communication on this internet is impossible. If you are new to HTML, learning <form> element is very important. Though there are variety of things that we can do using form, but here we are doing simple things with forms. Starting with FIELDSET & LEGEND <form> <fieldset> <legend>Fill in the form</legend> <p> Name: <input type="text"></p> <p> <input type="submit"></p> </fieldset> </form> I love FIELDSET & LEGEND 'coz they decorate form very well. Apart from forms you can think about using them in just text, where a title is followed by bit of its content. Using LABEL with FORM Check above example in your browser, and click on "Name", the input-field doesn't get selected. Isn't it? But if you do the slight change by wrapping "Name & Input" in <label></label>, then if you cl...

Confusion Of Difference Between ID & CLASS

 Everything worked when I used same ID for more than one element, I thought both ID and CLASS are same as far as CSS is concerned -- and my design worked. About validation, who cares, in the beggining. But seriously, thing is, one shouldn't use same ID for more than one element, and I think, for what ID stands for Identification; like you have an unique employee ID, or have unique driving license ID. Whereas every element may have same CLASS (it's like M size shirt of some brand which everyone can buy and wear), but not the same ID, that is specific to a element. If you want to write reusable CSS for lots of elements, then write them in CLASS; not in ID.

HTML Element -- Table

 Earlier I wrote about Table structure, but thing is like that if you don't practise enough, you tend to forget. And in Table structure if you put everything, then for a beginner it becomes complex, like, Table in HTML is too hard. So here I'm writing in simplified, very simplified way -- just few things about table and your work is done. <table border="1"> <caption> my table & chair </caption> <tr><td> first chair </td><td> second chair </td></tr> <table> If you don't want, you may not use <caption>. But without these three things <table>, <tr>, <td> and their closing </table>, </tr>, </td> -- table can't be made. Here <tr> stands for row (horizontal), in which you can put any number of column (vertical line); <td></td> stands for one column. So in above example we have put two columns, and have written something in them.

HTML Elements For Linking

 Without linking, WWW can't exist. It is linking which reaches us from one place to other, which enables our transactions and processes. When anybody learns HTML, first they learn about giving a link to a text (the most popular, a href). A element It works like: <a href="www.example.com"> some text </a> Link element It is used between <head> </head> of a webpage, for example, to link a style-sheet. See example: <link rel = "stylesheet" href = "style.css"> Area element It is used to link a specific part of an image, see example: <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Moscow_July_2011-16.jpg/220px-Moscow_July_2011-16.jpg" width="200" height="200" alt="Planets" usemap="#wow"> <map name="wow"> <area shape="rect" coords="0,0,50,50" href="http://example.com/"> <area shape="rect" co...

HTML Embedded Elements

 << img, image map, iframe, embed, object, param, video, audio, source, track, media, MathML, svg. >> Lets take each of them one by one, just by an example. Img element <img src=" " alt=" " height=" " width =" "> Image map element Generally we do link a whole image, but with images map we can link any part of the image, like the following example: <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Moscow_July_2011-16.jpg/220px-Moscow_July_2011-16.jpg" width="200" height="200" alt="Planets" usemap="#wow"> <map name="wow"> <area shape="rect" coords="0,0,50,50" href="http://example.com/"> <area shape="rect" coords="50,0,200,200" href="http://example.org/"> </map> Only trick is to use usemap="#____" with hash in img src; after it use this without hash in map....

HTML Element -- Footer

 This element is used at the last of a web-page, mostly used to give copyright information, to go up or go home, or to give few links. Example: <footer> © Copyright 2009-2018, All Rights Reserved </footer> If you want to give contact information inside <footer> element, then you should consider using <address> element inside footer for giving contact information.

HTML Element -- Address

 This element works like a visiting card, that shows a owner / author information: a physical or virtual address, where you can contact that person. It is simple to use, mostly used after a post; or, on the contact page of a website. Example 1 <address> Written by: Guest author You may contact him at Twitter or Facebook. </address> Example 2

HTML Elements - Details & Summary

 Please check the below example: <details> <summary>Man</summary> <p>Man is a good creature.</p> </details> Here summary is the topic, when you click it in browser, it expands and you find the hidden message "Man is a good creature." I love this two elements, very useful in writing FAQs for your website, in question-answer form. When reader click on a question, and it comes the answer. If you don't want to hide the message, use "open" attribute, like the following example. <details open> <summary>Man</summary> <p>Man is a good creature.</p> </details>

HTML Element -- DIV

 As the name signifies, DIV element stands for "division," it works as a container of text, image, audio and video. It is most commonly used element. You can use any number of DIV elements without restrictions. But with HTML 5, you should consider HEADER, ARTICLE, SECTION, MAIN, FOOTER, ASIDE and other elements -- instead of using DIV element everywhere. DIV element works like the following example: <div> Your text, image, audio and video goes here. </div>

HTML Elements - OL, UL, DL

  OL is ordered list , see example: <ol> <li> America </li> <li> England </li> <li> France </li> </ol> UL is unordered list , see: <ul> <li> America </li> <li> England </li> <li> France </li> </ul> In both OL and UL, <li> stands for "list." In HTML5, DL stands for description list , it works like the following way:

HTML Element - Blockquote

 I get confused with Blockquote, Cite and Quote Elements — that are <blockquote>, <cite>, and <q> elements. The most frequently used in blogging (Wordpress) that I see is <blockquote>, it puts apart part of text from the remaining text; it looks nice to the eyes if formatted well by using CSS. In short <cite> stands for reference, <q> for “ (quote). And <blockquote> stands for part of text from another source; as I see in blogging, it is also used for gaining attention, to summarise something, and to put little different matter. This element <blockqote> is used like the following example: <blockquote> Your text goes here. </blockquote>

HTML Element — Pre

 <pre> stands for preformatted text, means the text without certain sort of formatting; or in other words it removes certain formatting of the text. It is very useful in writing down codes, or to show raw writing style. Here is an example. <!-- following example without <pre> tag --> <p>There is a big space between this and that.</p> <p>I won't die unless I climb Everest 100 times</p> <!-- below example with <pre> tag -->

HTML Element — Hr

 Element <hr> stands for "horizontal rule," it displays a horizontal line. Good for a break between contents (preferably, paragraphs), when you want to show something which is different, sort of transition — but not entirely different from each other. If you want to use it excessively, use HTML <table> instead. Example: <p> Line 1 </p> <hr> <p> Line 2 <p> <hr>

HTML Style Elements — Mark, Sup, Sub, Cite, Q, Code, Time, A, Em, Strong, S, Small, I, B, U

 I call them style elements, 'coz they change the look and feel of text, see how they work. Mark <mark> element is used to hightlight the text. Example: <p>There were <mark> three men </mark> in a bookstore.</p>   Sup <sup> element stands for superscript. Here how it is works see the example. Example: <p>X<sup>2</sup>y <sup>2</sup></p>  

HTML Explain Elements — Dfn, Abbr, Kbd, Var, Samp, Ruby

 I call 'em explain elements 'coz they explain (or define) a term, very useful to provide suitable information with the associated term. dfn <dfn> element is "defining instance of a term," it says this particular term has been defined. Example : <p><dfn>PHP</dfn> is a programming language.</p>

HTML Edit Elements — Ins, Del, Datetime, Cite

 <ins> means insertion of text in a webpage, and element <del> means deletion from a webpage. You want to correct the following line in your webpage, where you wrote Tond instead of Bond, James Bond. Example <p> My name is Tond.</p> Correction in the following way. <p> My name is <del>Tond</del><ins> Bond, James Bond.</ins></p>   Note that <s> element, that is strike-through, exactly displays text like <del> element — only difference is <s> element isn't used for deletion (or say removal) from a webpage. Attribute <datetime> tells the date and time of insertion (ins) and deletion (del) of content from a webpage.