Results 1 to 5 of 5

Thread: Why isn't this working

  1. #1
    Join Date
    Oct 2012
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why isn't this working

    HTML Code:
    div#somediv h1{
              background-color:#000;
    }
    Now the above is just an example, but I saw someone typing CSS that way (and have seen it many times), but I can never get it to work. I always have to use something like:

    HTML Code:
    h1{
              background-color:#000;
    }
    Does it have something to do with my DOC type for the html you think?

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    CSS header file would say:

    HTML Code:
    @charset "utf-8";
    /* CSS Document */

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    is your <h1> inside a <div> with id="somediv"?

    HTML Code:
    <style> div#somediv h1{ background-color: red; }</style>
    <h1>Not in #somediv</h1>
    <div id="somediv">
        <h1>In #somediv</h1>
    </div>

  3. #3
    Join Date
    Oct 2012
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by traq View Post
    is your <h1> inside a <div> with id="somediv"?

    HTML Code:
    <style> div#somediv h1{ background-color: red; }</style>
    <h1>Not in #somediv</h1>
    <div id="somediv">
        <h1>In #somediv</h1>
    </div>
    Yes it is. However, Google Chrome, Fire Fox, and Safari ignore the css when I type it that way (yes lastest version of browsers installed).

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    what OS? seems to work for me (Google/Firefox/Safari on Win; Google/Firefox/Opera on linux).

  5. #5
    Join Date
    Oct 2012
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by traq View Post
    Well I just tried it in Mac Dreamweaver and preview in browser and it works fine. Windows 7 not so much.

Similar Threads

  1. Replies: 8
    Last Post: 11-23-2009, 04:00 AM
  2. Replies: 4
    Last Post: 10-24-2009, 07:07 AM
  3. javascript code not working in ie but working in firefox
    By sukanya.paul in forum JavaScript
    Replies: 2
    Last Post: 02-20-2009, 01:44 PM
  4. Replies: 1
    Last Post: 08-21-2008, 02:32 PM
  5. Script working/not working in Firefox
    By SawnDiddle in forum JavaScript
    Replies: 2
    Last Post: 03-27-2008, 07:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •