NOTEPAD++ TEXT STAYS THE SAME WHEN VIEWED IN BROWSER



  • I just recently started learning how to write in html and css so for the starters I decided to write a simple code and planned to expand from it as I learned. As you see I wrote simple text with not much place for error and wanted to view how does it look in a browser before writing anything serious. Alas viewing or even running the code on any browser didn’t seem to do much, and the text stayed looking the same as it did when writing it on notepad++. I’ve checked the code on https://codepen.io and the visualization of code was proper on there so the problem must be with the notepad it self I guess? Any advice?? I’m using Windows 10, 64-bit.
    image_2021-02-06_112600.png image_2021-02-06_112656.png



  • @Newbie104 said in NOTEPAD++ TEXT STAYS THE SAME WHEN VIEWED IN BROWSER:

    so the problem must be with the notepad

    No, the problem is you saved it as a txt file. HTML file is text but with a different extension, generally htm or html. Notepad did exactly what you asked of, so no fault there.

    Terry



  • Here’s what I see for what went wrong for OP.

    OP started writing his file in a new 2 (example) tab in Notepad++.

    At some point OP saved his file (e.g. Ctrl+s) and was prompted to save as new 2.txt. That entire filename was highlighted. OP didn’t want that name so OP overtyped with experimentas and pressed the Save button. Note that no extension was specified and the Save as type box said Normal text file (*.txt).

    Notepad++ correctly saved the file as experimentas.txt. OP didn’t notice the .txt or didn’t know he should care about that (new to Windows?/computers?).

    At some point after this, OP set the Language of the file, probably to HTML. Otherwise, we wouldn’t see the syntax highlighting shown in the screenshot.

    OP then requested the file be shown in a browser. As Terry indicates, the browser correct displays the file as text, because of the .txt extension on the file.

    Correct OP behavior would have been either to (a) set the Language before saving (in which case Save as type would have been displayed as “Hyper Text Markup Language”, and the extensionless file specified would have gotten .html added automatically) or (b) specify experimentas.html directly for the File name.

    Note: The above would be a bit different if the OP had Set Save dialog extension filter to .* instead of .txt for Normal Text ticked in the Preferences, but that is not the default setting.



  • Thank you for insight guys! I guess I’ll be paying attention to what type of file I am saving Ha ha ha. Cheers!


Log in to reply