• Login
Community
  • Login

my css code for color not working and error message when run

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
csscolorrun error
5 Posts 3 Posters 2.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Michelle Vedros
    last edited by Apr 5, 2023, 10:35 PM

    I can not get the background or text to change colors. I am using HTML and CSS. The javascript and margins structures work. When I run it, Notepad++ says: Syntax error line: 1, pos:1 and [null] line: 9, pos:4. I am using chrome and tried firefox. Here is my code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>My First Web Page </title>
    <meta name=“description” content=“Page Description Here”/>
    <meta http-equiv=“Content-Type” content=“text/html”; charset=“utf-8”/>
    <meta name=“viewport” content=“width=device-width, initial-scale=1”/>
    <style type=“text/css”>
    Body{

    	    background-color: red;
    		color:blue;
    		
    	}
    </style>
    	<script>
    		function myFunction() {
    			var x = document.getElementById ("fname");
    			x.value = x.value.toUpperCase();
    		}
    	</script>
    

    </head>

    <body>
    This is a Sample HtmL Document.
    This Javascript function will capitalize my name:
    Enter your name: <input type=“text” id=“fname” onchange=“myFunction()”>
    </body>
    </html>

    L 1 Reply Last reply Apr 5, 2023, 10:50 PM Reply Quote 0
    • L
      Lycan Thrope @Michelle Vedros
      last edited by Apr 5, 2023, 10:50 PM

      @Michelle-Vedros ,
      So what does this have to do with NPP? NPP is not a browser. It is a text editor, so I’m at a loss as to what you expect to happen.

      M 1 Reply Last reply Apr 6, 2023, 10:03 PM Reply Quote 1
      • M
        Michelle Vedros @Lycan Thrope
        last edited by Apr 6, 2023, 10:03 PM

        @Lycan-Thrope When I try to run it in NPP, it shows errors: Syntax line1:pos1 [null line 9: pos 4], but I don’t see the error. I was wondering if someone else could.

        P L 2 Replies Last reply Apr 6, 2023, 10:44 PM Reply Quote 0
        • P
          PeterJones @Michelle Vedros
          last edited by PeterJones Apr 7, 2023, 1:54 PM Apr 6, 2023, 10:44 PM

          @Michelle-Vedros ,

          Notepad++ doesn’t “run” HTML/CSS/JS, so your problem statement is incorrect from the get-go.

          In case you have confused Notepad++ with the PreviewHTML plugin that you may have installed – PreviewHTML uses an ancient rendering engine at its core, which (I believe) predates the HTML5 you are using – and I wouldn’t doubt if it gave anomolous results for anything but basic HTML. It is likely that other plugins that embed a rendering engine also may not be up to the task. Use a real browser for rendering HTML5, and let Notepad++ do what it’s good at: helping you edit the underlying source code.

          Once you do use a browser for rendering it, if you are still having trouble getting your HTML + CSS + JS to work, you should find a forum dedicated to HTML + CSS + JS, not a forum about the text editor that you happened to use to type that code: whether you type the code with Notepad++ (your best bet) or notepad.exe or COPY CON, the resulting HTML + CSS + JS will be the same. As it has been colloquially phrased, we cannot be expected to help you bake your cookies just because you use Notepad++ to type the recipie (see our FAQ for that reference).

          1 Reply Last reply Reply Quote 3
          • L
            Lycan Thrope @Michelle Vedros
            last edited by Apr 8, 2023, 3:39 AM

            @Michelle-Vedros ,
            In addition to what @PeterJones has pointed out to you, your code doesn’t work, even when you use the Notepad++ menu’s View->View Current File in->(browser choice) to view it. That’s because your code is in error. You need to consult an HTML/CSS/Javascript site, like the W3C Schools courses to better learn what you did wrong. I tried your code that way and in both Chrome and Firefox and it did exactly what you coded it to do. It just didn’t do what you wanted it to do, and that’s why I’ve just given you the link you need to follow to learn how to do it right.

            1 Reply Last reply Reply Quote 3
            2 out of 5
            • First post
              2/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors