It is necessary to generate a simple page in which the title will change, a bit of text and add, decrease elements of the list. How to do in html-I know, but in c # I try to write such info to a file, defining quotes with slashes - the document is written to the file correctly, and in a notebook all tags closing opening quotes and quotes are in place, but the browser does not see markup in this text. Maybe the fact is that the quotes when framing them with a slash are not the same as they should be?

UPD: the problem was probably caused by the fact that the html html code in # visual studio receives extra spaces between special characters (<>) when inserting, and I think that this requires discussion and attention and not a trivial typo.

Html file which is obtained

string content2 = System.String.Format( "<html>" + "<head>" + "<title> Документы {0} {1}</title>" + "< link href =\"../../favicon.ico\" rel=\"icon\" type=\"image/x icon\" />"+ "< link href =\"../../favicon.ico\" rel=\"shortcut icon\" type=\"image/x-icon\" />"+ "< link rel =\"stylesheet\" href=\"../../css.css\" type=\"text/css\" />"+ "</head>" + "<body>" + "{0} {1}" + "</body>" + "</html>", date, textBox_title.Text); #endregion File.WriteAllText("index.html", content2); 

Closed due to the fact that off-topic by PashaPash member Jul 31 '17 at 9:15 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - PashaPash
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • What does it mean the браузер не видит в этом тексте разметку ? - Andrei NOP
  • one
    Remove the spaces: <link , then it opens normally - Andrew NOP
  • @Andrey means that the browser opens it up as text, I will not translate it into hypertext commands - elislavkat
  • @ Andrew, yes, so ... copied me from the source without gaps! - elislavkat
  • html html code in c # visual studio when inserting gets extra spaces between special characters - send a bug report to them. - aleksandr barakin

2 answers 2

In accordance with the HTML specification p. 12.1.2.1, the first character of the opening tag is < , and the following characters must represent the name of the tag.

Thus, the space after < makes HTML invalid, and, therefore, it is not perceived by the browser. Spaces should be removed, for example:

 <link href = ... 

    In my opinion, it is better to use some HTML parser that allows you to work with HTML like an XDocument.