Search code examples
htmlvisual-studiocopy-paste

copy html as string to visual studio 2017


i'm writing html in visual code. example:

<header>
  <h1 style="text-align: center">Customer Name: 0</h1>
  <h2 style="text-align: center">Year: 2001 ,month: 12</h2>
  <h3 style="text-align: center">Total price: 100</h3>
</header>

and I want to copy paste the code to visual studio 2017

but in visual studio is look like:

  "<header>
  < h1 style = "text-align: center" > Customer Name: 0 </ h1 >

       < h2 style = "text-align: center" > Year: 2001 ,month: 12 </ h2 >

            < h3 style = "text-align: center" > Total price: 100 </ h3 >

               </ header > "

how can I paste it like this?

 "<!DOCTYPE html><html><head><title></title></head><body><header>

Solution

  • First you need to format your Html online and convert it into single line format

    Use

    Www.textfilter.com

    And also convert double inverted commas to single inverted commas

    Secondly when u use it in visual studio , if putting it in string variable u need to add @ behind your string

    string myhtmlstring = @"myanyhtmtags";
    

    This will prevent escaping and will work