1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

CSS Not Working

Discussion in 'HTML & Website Design' started by Dr. Anthony Rodriguez, Jun 13, 2020.

  1. #1
    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
    SEMrush
     
    Last edited by a moderator: Jul 3, 2020
    Dr. Anthony Rodriguez, Jun 13, 2020 IP
    SEMrush
  2. Saputnik

    Saputnik Active Member

    Messages:
    61
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Try this:

    h1 {color: red;}

    or

    h1 {color: #FF0000;}
     
    Saputnik, Jun 13, 2020 IP
  3. justinmidlet

    justinmidlet Member

    Messages:
    21
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #3
    change the style.css with this, and it will works.
    h1 {
    color: red;
    }
     
    justinmidlet, Jun 13, 2020 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,401
    Likes Received:
    1,875
    Best Answers:
    245
    Trophy Points:
    515
    #4
    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.
     
    deathshadow, Jun 13, 2020 IP
    JEET likes this.
  5. LeylaKondakova

    LeylaKondakova Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Try not to write properties of CSS in the body of HTML
     
    LeylaKondakova, Jul 3, 2020 IP
  6. Md Rofiqul Islam

    Md Rofiqul Islam Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    use h1 {color: red;}
    not h1{color=red}
     
    Md Rofiqul Islam, Aug 12, 2020 IP