#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Why this code does not work please help.


    <!DOCTYPE html>
    <html>
    <head>
    <style>
    #firstname #hometown
    {
    background-color:yellow;
    }

    </style>
    </head>
    <body>

    <h1>Welcome to My Homepage</h1>

    <div class="intro">
    <p id="firstname">My name is Donald.</p>
    <p id="hometown">I live in Duckburg.</p>
    </div>

    <p>My best friend is Mickey.</p>

    </body>
    </html>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    867
    Rep Power
    275
    If you want both #firstname and #hometown paragraphs to have yellow background then you need to separate each of their names with a comma.

    replace this
    Code:
    #firstname #hometown
    {
    background-color:yellow;
    }
    with this
    Code:
    #firstname, #hometown
    {
    background-color:yellow;
    }
    also, when using the <style> tag you should be using the type="text/css" attribute with it...like so <style type="text/css">

    Comments on this post

    • ravinder07 agrees

IMN logo majestic logo threadwatch logo seochat tools logo