how do i center this?

Discussion in 'Programming' started by sama3l., Jan 11, 2009.

  1. #1
    i want the logo in the center.

    <!-- logo -->
    <a name="top"></a>
    <table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
    <tr>
    	<td align="$stylevar[left]"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="$stylevar[titleimage]" border="0" alt="$vboptions[bbtitle]" /></a></td>
    	<td align="$stylevar[right]" id="header_right_cell">
    		<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]<else />&nbsp;</if>
    	</td>
    </tr>
    </table>
    <!-- /logo -->
    Code (markup):

     
    sama3l., Jan 11, 2009 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    <table align="center" border=...........................the rest of that


    Or if you have some text and you just want the image centered <p align="center"> <img tag> </p>

    Neither will validate. Both will work.
     
    Colbyt, Jan 11, 2009 IP
  3. sama3l.

    sama3l. Banned

    Messages:
    888
    Likes Received:
    92
    Best Answers:
    0
    Trophy Points:
    0
    #3
    that did not work....
     
    sama3l., Jan 11, 2009 IP
  4. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #4
    It is working here for me. I don't have the logo so all I am seeing is a broken image link in the header of a page and it on an html page not a php page and I don't have a css file that might be messing with it.

    Do you have it live somewhere?

    What exactly are you trying to do? Have a logo and an add in the header? One or the other?
     
    Colbyt, Jan 11, 2009 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Uhm, if you aren't going to have more than one TR, why are you using a table?

    On top of which it looks like you are trying to control something from a ton of scripted variables that should be controlled from the CSS.

    AND applying your width manually when a perfectly good containing DIV should handle that.

    <div id="logo">
    	<a href="$vboptions[forumhome].php$session[sessionurl_q]" class="logolink">
    		$vboptions[bbtitle]
    		<span></span>
    	</a>
    	<div class="advert">
    		<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]</if>
    	</div>
    <!-- #logo --></div>
    Code (markup):
    Everything else being done there should be in the stylesheet.... and I'm not 100% certain, but I have the feeling if I was coding it that would be the page's h1, not a DIV, without an ID. You're generating presentational markup - something that should have gone the way of the dodo when HTML4/CSS2 were finalized over a decade ago, and CAN go the way of the dodo since all the latest browsers are on-board for proper separation of presentation from content.

    Oh, that empty span is where I'd load the image. #logo .logolink span would target it. You set the anchor to display:block, set the same dimensions as the image, make sure the text stays inside that image, then absolute position the span over the text - that way images off the user has something to look at apart from ugly alt text, search engines see real content (since they ignore attributes like alt), and you can easily reskin the page without digging into the markup.
     
    deathshadow, Jan 11, 2009 IP
  6. weedman420

    weedman420 Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <center>
    ???
     
    weedman420, Jan 13, 2009 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #7
    /FAIL/ - what is this 1997?
     
    deathshadow, Jan 14, 2009 IP
  8. rjd22

    rjd22 Peon

    Messages:
    63
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    @deathshadow:
    if its working don't fix it.
    Why looking for something else if its working. If <center></center> is the solution use it.
     
    rjd22, Jan 14, 2009 IP
  9. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #9
    Not the solution in strict doctypes since that's invalid markup, and it was deprecated for a reason. That is presentation, presentation does not go in the markup unless you are stuck using decade old coding techniques that were a bad idea THEN. HTML should as much as possible say what things are, NOT how they appear.

    Which is why you see rubbish websites with code to text ratios of 20:1 instead of 1:1. Nothing like serving 40k of markup for 2k of actual content.

    Tags like CENTER and FONT, along with attributes like ALIGN, BGCOLOR - that bullshit shouldn't even be taught anymore and nobody writing NEW websites should be using that malarkey as it's a decade or more out of date. All it does is bloat out the markup making it harder to maintain, not make full use of caching models across multiple pages on the same site, and defeats the entire point of modern markup separating content (HTML) from presentation (CSS)
     
    deathshadow, Jan 14, 2009 IP
  10. rjd22

    rjd22 Peon

    Messages:
    63
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    yep I agree you shouldn't use it in strict markups but to come back to the topic I think setting this in the CSS for the logo div should put it in the middle I'm not sure tho.

    
    	margin: 0 auto;
    	margin-left:auto;
    	margin-right:auto;
    
    Code (markup):
     
    rjd22, Jan 17, 2009 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #11
    The latter two lines of that are redundant. Margin:0 auto; defines top and bottom as zero, left and right as auto - as such you don't need to say margin-left or margin-right.
     
    deathshadow, Jan 17, 2009 IP
  12. Seraskier

    Seraskier Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    
    margin:0px auto 0px auto;
    
    Code (markup):
     
    Seraskier, Jan 22, 2009 IP
  13. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #13
    Also redundant. You do not need to say a metric for zero, and the opposide side defaults to what is already set. The only reason to state all four sides like that is if they are DIFFERENT.

    GAH, BASIC CSS RULES PEOPLE!!!

    This is the EXACT same thing:
    margin:0 auto;

    That is all you need to say.
     
    deathshadow, Jan 23, 2009 IP