Weird ~ inline CSS works, external file doesn't

Discussion in 'CSS' started by Aztral, Jun 4, 2007.

  1. #1
    Okie.
    I have this weird problem.

    If I put
    #tabcontainer
    {
    font-family:Verdana;
    font-size:12px;
    font-style:normal;
    margin-right:15px;
    margin-left:15px;
    position:relative;
    top:70px;
    width:770px;
    height:360px;
    color:#36393D;
    }
    in the style section of the html file all works.

    If i move this to an external file (and include the file) it doesn't.

    Here's the html element
    <div align="left" id="tabcontainer">

    Another weird thing is if a delete cache, then click on link to go to this page it looks ok, but hitting refresh makes things look....not so good.

    Anybody ever seen anything like this before?:confused:
     
    Aztral, Jun 4, 2007 IP
  2. Crimsonc

    Crimsonc Peon

    Messages:
    616
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    why have you set the DIV to align to the left in the HTML? Most likely the browser doesn't know which to use, that or the CSS you've written. Don't use the align tag with DIV's if you can help it.

    Try float: left;
     
    Crimsonc, Jun 4, 2007 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Exactly. Get rid of the deprecated (obsolete) HTML markup if you can, that way you don't cause any conflicts with your stylesheet.

    Then make sure that the link path to your stylesheet matches the path to its actual location.
     
    Dan Schulz, Jun 4, 2007 IP
  4. Aztral

    Aztral Well-Known Member

    Messages:
    344
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    125
    #4
    thanks for input guys.

    W3C hasn't given me a replacement for <div align="left"> (yet). And it still works on modern browsers. I've never seen a browser "get confused" over it. I'll wait until W3C pulls their head out and gives me a rep...

    Anyway, removing align="left" didn't work. I do find it very weird i can put the css in the html file, but it bombs when i put it in external css file..Hrm
     
    Aztral, Jun 4, 2007 IP
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    Include, or link? If you include, it's like pasting from the clipboard. You may have introduced syntax errors.

    The align attribute for div is equivalent to css text-align. Eg., div {text-align: left;}

    If an attribute has been deprecated, it is very unlikely there is not a css option.

    cheers,

    gary
     
    kk5st, Jun 4, 2007 IP
  6. duilen

    duilen Active Member

    Messages:
    354
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Inline styles are higher on the precedence food chain. If you place that style somewhere in your external stylesheet it could be overwritten by styles further down the list. By placing it inline it generally wont be overwritten by external stylesheet. There are exceptions. (!important)
     
    duilen, Jun 4, 2007 IP
  7. Calrain

    Calrain Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi,

    I had the same problem and fixed it, and wanted to share the problem with other people as this page was ranked high on a Google search for the problem.

    When moving your CSS to the external file, it will fail if you also copy over the <style type="text/css"> and </style> markers that would have been in your inline CSS.

    Make sure the external CSS file only contains CSS commands.

    I made this simple error and that was the fix, ensure the external CSS is pure CSS, no <style... tags.

    Cheers
     
    Calrain, Jul 29, 2009 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yeah, a lot of people do tend to do that. Even veterans who just copy/paste without thinking about it.
     
    Dan Schulz, Jul 29, 2009 IP
  9. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #9
    Uhm, on what planet? Assuming you want to position the DIV, that's float:left; - assuming you want to align content inside it that would be text-align:left;

    Of course this is ANOTHER case where the snippet is next to useless without seeing what it is you are actually trying to do with it - especially since what you describe could be caused by any number of other issues in your markup or CSS.

    ***** align.... What is this, 1997?

    -- edit -- my bad, didnae even notice the thread necromancy... Sheesh, WTF is with the bump?
     
    Last edited: Jul 29, 2009
    deathshadow, Jul 29, 2009 IP