Introduction
(X)HTML rules ,like any other languages we have as c, cpp, Java, JavaScript, ruby pearl, python (X)HTML to have some set of rules some , the changing rules take place from one version to another version with an update in HTML there is a lot change in rules of HTML since with the updating of this language, rules are made in accordance with that so that it can be easy for anyone to code without any much more restrictions in this tutorial we will learn about some of them rules and look them closely.
Rule 1) HTML is not case sensitive.
Yeah, HTML is not a case sensitive language scenes many developer have an opinion of changing lowercase uppercase in their code and it make much more difficult for them to code easily so so this keeping in mind the version HTML made as such. If you found some where use of uppercase or lowercase the not awould not affect the output .
Example:-
<P> i am paragraph</P>
<p> i am paragraph</p>
<p> i am paragraph</P>
<P> i am paragraph</p>
(These above will have the same result unless of their uppercase or lowercase.)
Rule 2) attribute values may be case sensitive
This rule is little bit different as above we are saying that HTML is not case sensitive, now we are saying its attributes are case sensitive the reason here is that, let's understand with the help of an example.
Look these two lines below:-
Consider <img SRC="test.gif"> and <IMG src="test.gif">
What you found different in this the src and img.
If we look past history of the language we will found that these are equal and because the the image <img> and the <src>attribute are not case sensitive, unless of that in XHTML they should always be denotes as lower case however just because attribute names are not case sensitive under the its previous version this doesn't meet every aspect of attributes is case sensitive.
While if we put a close eye on another thing we conclude one more result.
That TEST.IMG OR test.img can be two different image ,as some UNIX based web server read this as two different images but as in another place we will found that filename are not case sensitive . This sometime make problem for website to load or transport on different servers.
Rule 3) (X)HTML is sensitive to a single whitespace character
(X)HTML is case sensitive to single whitespace character
Lets look at one example:-
<strong> b i g f o o t c o d e</strong><br>
<strong> b i g f o o t c o d e</strong><br><strong> b i g f o o t c o d e</strong><br>
All above code will be collapsed to single element as shown below
bigfootcode
bigfootcode
bigfootcode
Rule 4) (X)HTML follow a content model
We can use any tag any number of time in document but here is one catch something or some special tags our guide by some rules as well , it made specific by intention as they are used for performing a joint task , without confusing you much lets look at the example .
Example:-
<ul>
<p>i am breaking the contents model here </p>
<ul>
This above as you can see is where content model fails means this <ul> tag or unordered list is used to create a list view for document and its must contain <li> tags.
<ul>
<li>content 1</li>
<li>content 2</li>
<li>content 3</li>
<ul>
Rule 5) element should have close tags unless empty
Under older version of HTML some element have optional close tag like <br> break tag , you not need to be closed this tag it's totally depend on you, while in XHTML you must be required to close the tag or use the another format of self closing tag <br/> .
For better understand let's look at another example
Example:-
<p> i am not closed yet
<p> i am closed </p>
Where as you can see in above the paragraph tag is not closed while in second paragraph tag is closed this can be treated in many ways like this whole can be treated as one paragraph or can be considered as 2 paragraph because content model doesn't allow to enclose paragraph tag in another paragraph tag.
Rule 6) element should nest
While while choosing more than one tail on same line all content we should be nested properly de not need to be crossing each other this rule is not seem as such harmful , but introduce some ambiguity in prase trees.
So so why writing army document keep it check.
Let's see an example
Example:-
<i><b> please care me guys </b><i>
<i><b> please care me guys </i><b>
Rule 7) browsers ignore the unknown attributes and elements
If using any tag which is not known to any browser or you are creating your own tags then browsers will ignore that element or tributes this will not cause any other such but in some cases can be failure, browsers make best gases at structuring my phone contact and tend to ignore code that is obviously wrong.
<<Back next>>
0 Comments
if you have any doubt let me know in comment