my css code for color not working and error message when run
-
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> -
@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. -
@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.
-
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
orCOPY 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). -
@Michelle-Vedros ,
In addition to what @PeterJones has pointed out to you, your code doesn’t work, even when you use the Notepad++ menu’sView->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.