源代码与检查元素代码的不同之处在于更改标记位置

When my page is loaded from the server, source code differs from inspect element by changing the tags positions.
Here how the code looks in the view-source page

<!DOCTYPE html>
<html dir="rtl">
    <head>
        <link rel="stylesheet" type="text/css" href="css/mainclasses.css">
        <title>title  </title>
    </head>
<body style="margin:0px;">
<div id="wrapper" style="margin:0px auto;">

but when I inspect elements all the tags inside the head tag goes under the body tag, and two double quotations appear under the body tag.

<!DOCTYPE html>
<html dir="rtl">
<head></head>
<body style="margin:0px;">
""
<link rel="stylesheet" type="text/css" href="css/mainclasses.css">
<title>title  </title>
<div id="wrapper" style="margin:0px auto;">

The page works perfectly and all css properties appears and the title also appears.But I also want the HTML code to be good.

I searched for this and found many things that may cause this problem and none of them helped me.

  • There is no JavaScript code in my website, and I disabled all browser extensions so that JavaScript don't affect the page.I also checked the source tab in the developer tool and no JavaScript code were there.
  • I checked all my css properties and none of them causes this problem.(css also doesn't put strange chars).
  • The quotations that appeared are not spaces. I tried to put all my php code in one line and remove all unnecessary spaces and it didn't work.
  • I'm not using UTF8 BOM encoding, all files are UTF8 without BOM.so the strange chars are not due to file encoding.
  • I'm sure that the php files print the tags in the right order and don't print any quotation mark.
  • When I right-click the quotation marks in the developer tool,I only have the option Break on, and I can't edit it as HTML.
  • I tried to run the page from other web browsers and the problem didn't go.
  • I'm not using any framework.

What would be the cause of this problem, and how can I solve it?

I solved my problem.
I checked my HTML code. there were a symbol somewhere inside the head tag. I deleted the symbol and the HTML code in developer tool was corrected.