Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Use Id's and classes for divs?

    Idk why this isn't working, would really appreciate some help.

    This is my html:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    	<title> Zack's First Independent Practice Site</title>
    	<link type ="text/css"; rel = "stylesheet"; href = "CSS1.css"/>
    </head>
    <body>
    
    <p>Hello World!</p>
    <div class = "2">Hello</div>
    <div class = "3">Yay</div>
    </body>
    </html>
    This is my CSS:
    Code:
    p{
    font-family: Verdana;
    color: Violet;
    margin: auto;
    
    }
    div{
    border: 2px solid black;
    height: 25px;
    width: 80px;
    display: inline-block;
    background-color:yellow;
    }
    
    .1{
    background-color: red;
    
    }
    .2{
    background-color: blue;
    height: 300px;
    width:400px;
    
    
    }
    .3{
    background-color: orange;
    
    }
    I just don't get why it isn't using the formatting I made for class 2 and 3. Would really appreciate help and an explanation. Thanks in advance.
    Last edited by VIPStephan; 04-10-2013 at 01:58 PM. Reason: added code BB tags

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    classes and id's cannot start with a number, try coming up with different class names and see what happens

  • Users who have thanked DanInMa for this post:

    dekkahs (04-12-2013)

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,726
    Thanks
    6
    Thanked 1,013 Times in 986 Posts
    And if you post any code please put it in between [CODE][/CODE] tags. It makes scanning your posts much easier. You can do this by clicking the small ‘#’ icon above the reply field.

    Also, this is wrong:
    Code:
    <link type ="text/css"; rel = "stylesheet"; href = "CSS1.css"/>
    Remove the semicolons. An HTML element with attributes must look like this:
    Code:
    <element attribute1="value" attribute2="value" attribute3="value">…
    Last edited by VIPStephan; 04-10-2013 at 02:01 PM.

  • Users who have thanked VIPStephan for this post:

    dekkahs (04-12-2013)


  •  

    Posting Permissions

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