Do I need a !DOCTYPE declaration in a php file with html?

前端 未结 10 1103
面向向阳花
面向向阳花 2020-12-15 03:16

I have a php file with my website content in it. The file needs to be .php because i get some variables first and then use it later in the website content. Like this example

相关标签:
10条回答
  • 2020-12-15 03:48

    The same rules for HTML apply equally, whether they're plain HTML files, or HTML files with embedded PHP. YOu need a doctype in every circumstance you'd need one in plain HTML.

    By the way, there's whitespace between the end of the first block oh PHP code and the doctype. I seem to remember that whitespace before the doctype can be problematic (though that might only apply to XHTML)

    0 讨论(0)
  • 2020-12-15 03:48
    <!DOCTYPE HTML>
    <table  style="position:absolute; bottom:20%; right:40%;" width="150">
    

    if you put <!DOCTYPE HTML> in php file some styles will not work properly, some alignment problems.

    0 讨论(0)
  • 2020-12-15 03:50

    You should always put a Doctype in your html, no matter how the html is built.

    w3 doctype list

    0 讨论(0)
  • 2020-12-15 03:53

    Yes, you should have the DOCTYPE declaration, since what you send the browser is HTML, not PHP.

    The declaration tells the browser that you are using HTML 5 and tells it how to render it.

    0 讨论(0)
提交回复
热议问题