Results 1 to 7 of 7

Thread: [RESOLVED] CSS Behavior between FF2/Safari1.2 and IE7/Opera9

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Resolved [RESOLVED] CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    The following is a simplified example of a larger doc that I have.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11-strict.dtd">
    <html>
    	<head>
    		<title>Feedback Form - Widgets and What's its</title>
    		<style type="text/css">
    			.DivClass {
    				font-size: 600px;
    			}		
    			.HClass {
    
    			}		
    		</style>
    	</head>
    	<body>
    		<div id="MyDiv" class="DivClass">
    			<h1 class="HClass">Some H1 Text</h1>
    		</div>
    	</body>
    </html>
    The behavior for IE7 and Opera 9 is that the font-size does not change. Safari 1.2 and Firefox 2 are inheriting from the div's class.

    My question is, without having to specify a font-size for h1; is there a way to tell Safari and Firefox not to inherit from the parent?

    I've attempted to use both classes and class selectors. Neither seem to work and I am only allowed to work with classes (I won't have information about the element's ID during the page's render; for unrelated reasons).

    Any help is appreciated.

    -Thanks.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    Code:
    			.DivClass {
    				font-size: 600px;
    			}		
    			.HClass {
    				font-size: none;
    			}
    ..I *think*....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    Thanks tg,

    I gave it a shot:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11-strict.dtd">
    <html>
    	<head>
    		<title>Feedback Form - Widgets and What's its</title>
    		<style type="text/css">
    			div.DivClass {
    				font-size: 600px;
    			}		
    			.HClass {
    font-size: none;
    			}			
    </style>
    	</head>
    	<body>
    		<div id="MyDiv" class="DivClass">
    			<h1 class="HClass">Some H1 text</h1>
    		</div>
    	</body>
    </html>
    Firefox 2.0 and Safari still rendered it at 600px. Any other ideas? I'm really hard up on this one...

    Edit:
    --Hold on, I screwed up; style is outside of the brackets. Let me retry--

    Edit:
    Even after I fixed the above snippet so the styles were correct, Firefox and Safari still had the same behavior as I mentioned before.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    I won't have information about the element's ID during the page's render; for unrelated reasons
    Let me guess, it's .Net auto-generated.

    Anyway, the answer is no. Unfortunately, both behaviours are perfectly within the specification: all browser override the font size of the h1 with the value from the HTML default style sheet. However, Safari and Firefox follow the (purely informative; it is not a violation of the spec not to do so) recommendation of the CSS specification and make the text size of h1 "2em", meaning twice the size of the parent element, whereas Opera and IE give it an absolute size.

    So you either have to explicitly specify the font size or remove the specification on the div.

    Which leads you to another problem: there is no way to specify the "browser default value" for the font size. Replace it once, and you have to replace it everywhere, or risk inconsistencies.

    Which makes the best solution to not specify the size on the div.

    Alternatively, you can force IE and Opera into the "more compliant" (i.e. following the recommendation of the spec) behaviour by explicitly forcing h1's font size to be 2em:
    Code:
    h1 { font-size: 2em; }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    Generally speaking it is a good idea to "reset" styles when doing CSS to ensure better cross browser results. This is one example when "weird" things happen due to differences between browsers default settings. Of course the downside is that you just have to do more code, but when you do it a couple of times you end up with some general stuff you do every time, it gets into rather simple copy'n'paste line.

  6. #6

    Thread Starter
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    Quote Originally Posted by CornedBee
    Let me guess, it's .Net auto-generated.
    Actually, no. We built our own framework and the pages are themeable (based on user). The problem is, the developer building the page with the framework doesn't necessarily have to specify an ID of every element (we'll generate a guid instead and the classes some from the controls they used). But since the elements are being grouped (Say one group is "button" but it also has a more defined group scope of "acceptbutton") I need to determine a way that if something has styles on the wrapping object, it doesn't follow that, but insteeads follows the classes.

    I'm not sure how this will end up working. Thanks though.

  7. #7

    Thread Starter
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: CSS Behavior between FF2/Safari1.2 and IE7/Opera9

    I was a little on edge on Friday; making mountains, ect ect. After reading the responses again and starting with a fresh perspective, it looks like I can make this work. Regulating what you "can" and "can't" do style-wise is the next level up from where I am. I was attempting to put the logic in the most raw object I had.

    Noob mistake.

    Thanks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width