Hi! I am learning HTML/CSS. Here's some HTML code for index.html : <!DOCTYPE html> <html> <head> <title>Money By Tony</title> <meta chartset="UTF-8"> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Home</h1> <p style="color:red;"> Hello world! </p> </body> </html> Code (markup): Here's some CSS code for style.css : h1 {color=red;} When displayed , "Home" is not "red" but "Hello world!" is "blue." What am I doing wrong? Thanks! Dr. T
1) Use a : not a = 2) It's charset, not chartset. Char, short for character. "Character set" 3) The charset META should be before all content bearing elements as it determines what text characters are valid. Failing to do so forces the browser to restart over from the beginning when it hits said META tag. TITLE is a "content bearing element". 4) 99% of the time you see style="" you're looking at incompetence and ineptitude. Don't do that. The only time style="" should be used is for things like tag clouds, or HTML based charts and graphs, where values like font-size or width/height HELP convey meaning. Otherwise presentation does NOT belong in your markup.
It is highly recommended to write the CSS only in the style.css file that you have in the head section of you page, not in the HTML.
You can write this css in style.css or inline under <style> </style> block and add the following css rule h1 { color:red; } if sill you are not getting the desired result you can mark rule as 'important' with the following rule h1 { color:red !important; }