1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Basic CSS.

Discussion in 'Web Design' started by joshmacca12234, Jan 21, 2014.

  1. joshmacca12234

    joshmacca12234 Newbie

    Joined:
    Jan 12, 2014
    Messages:
    8
    Likes Received:
    1
    Occupation:
    Learning
    Location:
    earth
    <!DOCOTYPE html>
    <html>
    <head>
    <Title>Basic CSS</title>
    <style>
    * {
    background-color: #555;
    margin: 0px;
    font-family: arial, helvetica, sans-serif;
    }
    #head {
    background-color: black;
    height: 56px;
    }
    #div, h1 {
    color: white;
    position: absolute; top: 5;
    background-color: black;
    margin-left: 500px;
    }
    p {


    color: red;
    position: absolute; top: 0px;
    background-color: black;
    </style>
    </head>
    <body>
    <div id="head">
    <h1>CSS</h1>
    </div>




    <p>Login || Sign up</p>


    </body>
    </html>

    Any mistakes, please correct.
     
  2. mypmmail

    mypmmail Junior Member

    Joined:
    Jan 31, 2008
    Messages:
    111
    Likes Received:
    27
    Other than a simple 'doctype' typo or matching of braces, I don't see anything wrong.

    But the question is what is your objective for doing this?

    If it's for learning and trial and error, you can go to hxxp://jsfiddle.net/ to test out your ideas.
     
  3. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,354
    Likes Received:
    5,415
    Gender:
    Male
    Location:
    South Africa
    Home Page:
    You've referenced an unknown ID named div, you should correct it to:
    Code:
    div h1 {
    // CSS
    }
    
    OR

    Code:
    #head h1 {
    // CSS
    }
    
    Also the DOCTYPE typo, as previously mentioned.

    Try also formatting your CSS a little bit better, for the sake of readability.

    Edit: Also, change the * attribute to "body", for stuff like background colours and fonts. Simply because I consider it bad formatting. So do some other people:
    http://css-tricks.com/forums/topic/the-selector/
    http://stackoverflow.com/questions/1714096/why-is-the-css-star-selector-considered-harmful

    It also can produce unexpected complications if you're trying to style individual elements later on.
     
    • Thanks Thanks x 1
    Last edited: Jan 21, 2014
  4. joshmacca12234

    joshmacca12234 Newbie

    Joined:
    Jan 12, 2014
    Messages:
    8
    Likes Received:
    1
    Occupation:
    Learning
    Location:
    earth
    I code differently that you, so i do not need to change anything.
     
  5. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,354
    Likes Received:
    5,415
    Gender:
    Male
    Location:
    South Africa
    Home Page:
    Lol, you ask for advice, and then tell me you don't need to change anything?

    You're welcome for the help kid. :fing02:
     
    Last edited: Jan 21, 2014
  6. keadams26

    keadams26 Regular Member

    Joined:
    May 9, 2009
    Messages:
    462
    Likes Received:
    274
    Home Page:
    Wow. Never ceases to amaze me.
     
  7. themubeen

    themubeen Junior Member

    Joined:
    Feb 13, 2011
    Messages:
    121
    Likes Received:
    15
    use general properties and colors inside body tag instead of assigning to *