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
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts

    Exclamation Center text - How do I go wrong?

    The following is the "style" part of my index page.
    I have removed a "center" tag in order to update the page and used the entry in red to try to center the "greet" print.

    It doesn't work. What am I doing wrong?

    effpeetee


    Code:
    <style type="text/css">
        h1,h2 {font-family: Arial;}
        h1 {color:red}
        h2,h3 {color:cyan}
        h6 {color:cyan}
        h5,h5 {color:white}
        h6,h5,h5,h3,h2,h1,p {
        margin: 0;
    }
    #clockbox0{
        position: absolute;
        left: 1em;       
        color:white
    }
    
    #clockbox1{
        position: absolute;
        right: 1em;
        color:white
    }
        
    #greet{color:red;
    text-align:center}
    
    p#pc {margin-top:20px;margin-left:15px;}
    
    </style>
    
    <script type="text/javascript" src="include.js"></script>
    <script type="text/javascript">
    
    function greet() {
      var todaydate = new Date();
      var timeis = todaydate.getTime();
      todaydate.setTime(timeis);
      var houris = todaydate.getHours();
      if (houris >17) display = "Evening";
      else if (houris >11) display = "Afternoon";
      else display = "Morning";
      var title = document.title;
      var welcome = ("Good " + display + ". Welcome to the Taylor Website");
      document.write(welcome);
    }
    -->
    </script>
    
    </head>
    <body>
    /*I used to have the '<center>' tag here*/  
    www.exitfegs.co.uk
    
    <div id="wrap">
     <span id="clockbox0"></span><span id="clockbox1"></span><br /></div>
        <h1>
        <span id="greet">
    Last edited by effpeetee; 05-19-2007 at 09:51 AM. Reason: Readability

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    We need to see the rest of your html, but from the snippet you provided you aren't using the h1 element correctly. You have a span but a span will only be the width of the text in it so it will never center. If you change this
    Code:
    <div id="wrap">
     <span id="clockbox0"></span><span id="clockbox1"></span><br /></div>
        <h1>
        <span id="greet">
    to this
    Code:
    <div id="wrap">
     <span id="clockbox0"></span><span id="clockbox1"></span><br /></div>
        <h1 id="greet">
    Your text will center. Be sure to remove the closing </span> tag. I suggest you look into the term 'html semantics' as from the code I've seen you post you really need to understand semantics. Much of your code is used in an incorrect way.
    Last edited by _Aerospace_Eng_; 05-19-2007 at 10:22 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Thank you,
    The modification worked fine.
    I am at the moment reading a book which is dealing with Semantics.

    "Cascading Style Shets" by Owen Briggs, Steven Champeon etc.,

    Obviously I have far to go. But I'll stick with it.

    Kind regards,

    effpeetee

    www.exitfegs.co.uk


  •  

    Posting Permissions

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