SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Style in Head with XML error

    I'm getting a bizarre error from FF Firebug:
    Code:
       missing } in XML expression    margin-bottom: 110px;
    Here's the context between (<head> and </head>):
    Code:
    <comment>
         <style>
         #AlientameLinerNotesTop	{
         	margin-bottom: 110px;
         }
         </style>
         </comment>
    And here's the doctype:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    Didn't intend to create any XML and I don't get that there is a missing } either. All I intended to do was create a "non-IE browsers" style override. The technique worked perfectly on another site:
    Code:
    	<comment><style type="text/css" title="">
        		#BigOverview	{
        			margin-bottom: 0px;
        		}
        	</style></comment>
    Sometimes the alignment resolutions in IE and FF don't work exactly the same. So I've taken to making adjustments for the compliant browsers by inserting a style within the document that will override the CSS file and be invisible to IE through the use of <comment></comment>.

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Just so you know there is no such thing as a <comment> tag in (X)HTML, Maybe if you remove that you'll have better luck.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I know. It's an IE only thing, which is why it can be used to hide things from IE. FF sees the style which, by virtue of it being closer to the html, overrides the CSS file which is external. It's a hack, and I would rather avoid it, but I don't know of another way yet.

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Try using conditional comments instead. They only work in IE and won't bother any other browser.

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried this:
    Code:
    <style type=&quot;text/css&quot;>
        <!--[if gte IE 5]
        #AlientameLinerNotesTop	{
        	margin-left: 400px;
        	font-family: Tahoma;
        }
        <![endif]-->
        </style>
    Didn't work. What am I doing wrong here?

    When I put the same snippet of code in the body of the document it shows up in IE but not FF.
    Last edited by cweaver; Sep 30, 2006 at 14:52.

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This didn't work before because I had inadvertently told my PHP to put the stuff within a script area. I was focussed on the style tags and didn't notice the script tags above and below them.
    Code:
    <!--[if gte IE 5]>
      <style type="text/css" title="">
      
      #AlientameLinerNotesTop	{
      	margin-left: 0px;
      }
      
      </style>
      <![endif]-->
    I like this better than the <comment> tags method because with this I'm creating CSS files that are for W3C compliant browsers while making what exceptions I must in the head of each page.

    While we're on the subject, if anyone would like to chime in with "It's better done this way..." I'm all ears.

    Thanks.

  7. #7
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's better to understand what's causing the bug and possible ways around it without any hacks.
    Simon Pieters


Bookmarks

Posting Permissions

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