two validations in HTML page.

Dear Experts,

What will happen if I'll make two validations in my HTML page like these?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


Thanks,

Jimi J
JaimeJegoniaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

123654789987Commented:
JaimeJegoniaAuthor Commented:
May be you are right but it was not clearly stated. However my real interest is, am I getting the two standards or the 1st one is overwritten by the the second one? In effect, I'm getting only the second one.

One of the concerned also is, it slow me down a little because I'm checking with the 2 sites on page loading.

Any idea?

Thanks.

 
AGBrownCommented:
The problem is more whether or not the two definitions are complimentary. AS I understand it, and please correct me if I get this wrong:
- XHTML 1.0 transitional is a tighter version of HTML 4, so you can be XHTML 1.0 transitional AND Html 4.0 if you are XHTML 1.0 transitional.
- But, if you are HTML 4 you are not necessarily XHTML 1.0 transitional.

Is there a reason you want to use both? XHTML 1.0 sort of implies HTML 4.

Andy
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

AGBrownCommented:
PS I'm pretty certain you can't have two DOCTYPE declarations. I can't find anything saying that you "can't", but more importantly there is nothing saying that you "can" either. That msdn link doesn't specify that you can, it just puts two next to each other as examples of what you can use

As an experiment, I pulled the html for an XHTML page from my site, and put two doc type declarations at the top:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
   "http://www.w3.org/tr/html4/loose.dtd">

I then passed it through the w3.org validator (http://validator.w3.org/) and it failed, where previously it passed. I think the reason is that once you pass the first DOCTYPE line, you are assumed to have started your document proper, and the schema specified by the DOCTYPE does not include DOCTYPE.

I'm stabbing in the dark a bit here, but it seems to all make sense. I have looked, and I just can't find anything to confirm this though. The best I can find is the original DOCTYPE definition in Html 3.2 (http://www.w3.org/TR/REC-html32.html) which says "Documents start with a <!DOCTYPE> declaration followed by an HTML element containing a HEAD and then a BODY element:". This would seem to imply that HTML documents according to that specification only have one DOCTYPE. If you look at the HTML 4.01 specification, then it also always mentions DOCTYPE in the singular (http://www.w3.org/TR/html4/struct/global.html).

Curioser and curioser. If I had to commit to an answer, I would say you are only allowed one DOCTYPE, as it doesn't make sense to have two. I wait to be proved wrong ...

Andy
JaimeJegoniaAuthor Commented:
Andy,

I am also about 95 convince that we can't make 2 DOCTYPE declarations. I am only tempted to use it for some display instances between IE and Firefox and I thought doing it would solve the issue. Anyway, thank you very for pulling lot of information for me. I'll just wait for sometime until we get certain of what we are trying to prove.


Thanks.  

AGBrownCommented:
I checked with a colleague, between us we are 99.999999% sure you can't have two.

Are you sending out aspx pages? There is probably a way of changing the header based on the User Agent part of the request headers.

Andy
JaimeJegoniaAuthor Commented:
Andy,

If you can a way of changing the header based on the User Agent part of the request headers, I will appreciate it.  If you can indicate some possibilty, instead of opening another issue, I will just increase the points of this question.

Thanks.
AGBrownCommented:
Are you using asp.net? Which version?
JaimeJegoniaAuthor Commented:
I am using ASP.Net 2.0 C# language.
AGBrownCommented:
I'll assume you are, and that you are using C# and Visual Studio. I have tested this, and it works.

Open your aspx, and put the following definition at the top of the markup, in place of your DOCTYPE:
<asp:literal id="ltDocType" runat="server"></asp:literal>

Then put the following in your Page_Load:
            private void Page_Load(object sender, System.EventArgs e)
            {
                  if (!IsPostBack)
                  {
                        switch (Request.UserAgent)
                        {
                              case "FirefoxUserAgent":
                                    this.ltDocType.Text = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Strict//EN\" >";
                                    break;
                              default:
                                    this.ltDocType.Text = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" >";
                                    break;
                        }
                  }

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AGBrownCommented:
Lol, posted that just as you did - that was a good guess!
JaimeJegoniaAuthor Commented:

Andy,

It seems to be working but I have a problem how to include the http, because i want to switch between DOCTYPE in my original question:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

How can I do it.

Thanks.
AGBrownCommented:
what is the problem you are getting? Is it a compilation problem? Make sure you delimit any occurences of " that are in the string with a \, so you have:

                         case "FirefoxUserAgent":
                              this.ltDocType.Text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
                              break;
JaimeJegoniaAuthor Commented:
I'am always getting the default, may be the "FirefoxUserAgent" is not right.  What's the IE user agent?
AGBrownCommented:
Ok, sorry, I didn't know that - I just wacked that in. You need to look up the different user agents on google. There are lots of pages that list them, like http://www.psychedelix.com/cgi-bin/free-search.cgi?template=free-search-detail.html&dbname=allagents.csv&key2=id_m_989&action=searchdbdisplay. Because of the variable nature of the useragents, you might need to find a site that shows you how to do a comparison to get the key parts out of it. If you have to do that then you won't be able to use switch like that, you'll have to write a function that returns a user agent type, maybe

enum UserAgentEnum
{
FireFox,
IE,
Other
}

public UserAgentEnum GetUserAgent()
{
if (<pseudocode> MatchesFireFoxStrings)
   return UserAgentEnum.Firefox
else if (<pseudocode> MatchesIEStrings)
   return UserAgentEnum.IE
else
   return UserAgentEnum.Other
}

then the switch would be:

switch (this.GetUserAgent())
{
case UserAgentEnum.Firefox:
    // do firefoc doctype
    break;
...
...
...
}
}


Alternatively, run your code in debug mode from IE and firefox, and pick up the value of the Request.UserAgent and use that for the switch, in the short term.
JaimeJegoniaAuthor Commented:
Andy,

These what I've got:

MSIE 6.0
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

Firefox
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1


This is what I did to make it work, at least:

 if (!this.IsPostBack)
        {        
          if ((Request.UserAgent.IndexOf("MSIE 6.0") > -1)||(Request.UserAgent.IndexOf("MSIE 5.5") > -1) )
               {
                 this.ltDocType.Text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
               
               }
          else
               {
                 this.ltDocType.Text = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Strict//EN\" >";
               }        
}

I'm closing this request already and opening another request how to verify what present on that Request.UserAgent using split()

Thank you very much time and efforts.



Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.