Search code examples
c#htmlpreview

How to preview HTML file in C#


How i can preview simple HTML file (C:\Users\Test\Desktop\test.txt) in C#?

Simple HTML Code;

<html>
<head>
<style>
    body
    {
        background:blue;
    }
</style>
<script>
    alert("test js");
</script>
</head>
<body>
    <buton>test<buton>
</body>
</html>

Solution

  • The way to see what an HTML file will look like in a browser is to open it with a browser. C# is a software development language and can be used to write applications that will do what you want. If you're using Visual Studio there are extensions that will do what you're asking but I'd suggest simply opening it in a browser.

    In Windows you can drag and drop the file, but you'll want to change the extension to "html" so the browser "knows" what to do with it. If you drop it in with a "txt" extension it'll just display the text.

    BTW, you'll want to correct the spelling of "button" and close the tag with "/button" or it won't show up the way I think you're wanting.