Jump to content

  • Log In with Google      Sign In   
  • Create Account

[web] CSS is pi***ng me off!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Orbital Fan   Members   -  Reputation: 106

Like
0Likes
Like

Posted 30 March 2011 - 02:44 PM

Sorry for the rant-ish title. I've just spend the evening fighting with CSS to do what I want it to do. I'm not going to bore you with specifics, but just wanted to get it off my chest, and ask what tools (if any) do you guys/gals use to author CSS.

Coming from a C++ background, HTML and CSS are a bit of a black-art. It's all very "well you want the right-aligned, but on some browsers it might be a bit more to the left".

I spend ages trying to get my HTML page to do what I want in Chrome, gave up, then tried IE and it renders fine!! So WTF is Chrome doing differently?

The "Inspect Element" tool in Chrome is pretty useful, but I'm still struggling A LOT with all this stuff.

HELP!

ps. Any advice on tools or methods to improve my CSS authoring?

Sponsor:

#2 benryves   Members   -  Reputation: 1998

Like
1Likes
Like

Posted 30 March 2011 - 04:58 PM

Are you in standards or quirks mode? (Do you have a sane doctype in your HTML?) In IE, if you bring up the developer tools (F12) does it say Standards or Quirks mode in the toolbar?

Most modern browsers are pretty consistent as long as you are in standards mode. In quirks mode, just about anything goes...
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

#3 jbadams   Senior Staff   -  Reputation: 19431

Like
0Likes
Like

Posted 30 March 2011 - 05:01 PM

1. Learn and know common problems with different css implementations. You could go out and research this up-front, but generally the majority of it will come over time as you run into each individual problem. When you experience a difficulty you should do some searching to see if it's a known issue -- there will usually be known work-arounds as well.

2. Use good editing tools. There generally isn't all that much to a css file visually even when it gets complicated, but you should still be using a well-featured editor you're comfortable with. Features you might want to look for include syntax highlighting, auto-completion, the ability to "collapse" or "fold" sections of the document away, and a good find-and-replace feature.

3. Use good browser tools. The tools in Chrome that you're already aware of are quite good. The FireBug extension for FireFox is another excellent example.

#4 Orbital Fan   Members   -  Reputation: 106

Like
0Likes
Like

Posted 31 March 2011 - 08:19 AM

Thanks for the tips.

I'm using Eclipse which has good auto-completion, etc.

I'll have a look at which mode IE was in when I got home tonight.

Regards.

#5 touch_the_sky   Members   -  Reputation: 141

Like
1Likes
Like

Posted 31 March 2011 - 08:21 AM

If you haven't done so already, try validating your markup - always start with creating the best markup you possibly can, for example you may have an unclosed div which would screw up the rendering of a page. In most cases IE would be the misbehaving one (if you follow standards and good practice rather than building it for IE) ;)

Chrome tools and Firebug are already mentioned, for "easy CSS" you may try the likes of Stylizer - you can download the trial and see if it's good for you.

***[[[And basically, educate yourself for a start - you'll then notice that markup is more than 'copy'n'pasta of some template' - each element has it's purpose, you'll learn about doctypes, microdata, semantics, why it's good for you to have an alt tag even if you're not bothered about accessibility (or why by creating an all-flash website you're hurting yourself). You'd eventually get to know CSS better, the browsers and what to expect out of them, etc etc. Google around, you can check those 2 for some reading: htmldog , A list apart . If you get to streamlining your work have a look at 960gs and HTML5 boilerplate. Avoid w3schools and THIS is why;)]]]

*** - 99.99999% not relevant as you seem to just want to 'get your site sorted quickly & easily' rather than becoming a top-notch frontend dev.

Hope any of this helps;)

#6 AdrianC   Members   -  Reputation: 602

Like
0Likes
Like

Posted 31 March 2011 - 09:59 AM

Basically IE misinterprets the box model, which screws up the site (or w3's misinterpretation, however way you want to look at it). Certain doctypes are supposed to fix it, but I couldn't get it to work. What I did eventually was use a style sheet for IE, and another for everything else.

#7 Dino   Members   -  Reputation: 172

Like
0Likes
Like

Posted 05 April 2011 - 07:53 PM

I can help out, but you have to let me know what are you trying to accomplish. I can tell you that IE will make it difficult to get things looking right, especially in quirks mode. First thing, add to top of all your documents the following line (before the <html /> tags) :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
That will force all IE browsers to render using a strict adherence to the W3 rules, or at least an attempt at strict adherence.

Second, get a really good understanding of the box model and CSS hierarchy, which is probably the most mis-understood part of HTML development. Most people don't realize that you can apply multiple styles to the same HTML element. For example:
<div class="ContentPane FloatingLeft">This is my content</div>
This HTML applies 2 styles to the DIV, ContentPane and FloatingLeft.

Third, sometimes it helps to force all the HTML elements to a common set of rules so that all styles are set to a common set of features that would be applied in all browsers.

But to really help, some HTML examples would be nice.
Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.

Visit http://ajaxmud.net for information about developing web-based games

#8 Orbital Fan   Members   -  Reputation: 106

Like
0Likes
Like

Posted 06 April 2011 - 10:28 AM

I can help out, but you have to let me know what are you trying to accomplish. I can tell you that IE will make it difficult to get things looking right, especially in quirks mode. First thing, add to top of all your documents the following line (before the <html /> tags) :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
That will force all IE browsers to render using a strict adherence to the W3 rules, or at least an attempt at strict adherence.

Second, get a really good understanding of the box model and CSS hierarchy, which is probably the most mis-understood part of HTML development. Most people don't realize that you can apply multiple styles to the same HTML element. For example:
<div class="ContentPane FloatingLeft">This is my content</div>
This HTML applies 2 styles to the DIV, ContentPane and FloatingLeft.

Third, sometimes it helps to force all the HTML elements to a common set of rules so that all styles are set to a common set of features that would be applied in all browsers.

But to really help, some HTML examples would be nice.



Hi, yeah I was going to ask about the DOCTYPE, I do have mine set to:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

as that's what Eclipse automatically put in for me.

I've purchased a book on CSS, which has a whole chapter on the box model. Time to get reading :)

The tip about multiple styles on a DIV is interesting - would never have considered it.

Thanks

#9 Dino   Members   -  Reputation: 172

Like
0Likes
Like

Posted 06 April 2011 - 11:33 AM

With regards to the Box Model, the AdrianC is partially right in that IE misinterprets the model model rules.

According to the W3C, the rule states that the height of a block element is : Margin + Border + Padding + Content height. Take the following element as an example:
		<div style="margin: 10px 0px; padding: 10px 0px; height: 30px;">
			This is a test
		</div>

According to W3C, the height of this element should be 70 pixels. FireFox and Chrome all show it as 70 pixels. The problem comes with IE 7 and IE 8 Quirks mode. Regardless of how it comes up with the number, it's not W3C compliant and it's quite annoying. On the bright side, IE 8 Standards does handle it properly. And with the DOCTYPE set, you shouldn't worry about Quirks mode. IE7 only has ~5% of the browser share anymore and most of those users are business users so I wouldn't worry too much about the compatibility issue with IE and the box-model.
Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.

Visit http://ajaxmud.net for information about developing web-based games

#10 benryves   Members   -  Reputation: 1998

Like
0Likes
Like

Posted 06 April 2011 - 12:26 PM

On the bright side, IE 8 Standards does handle it properly.

Even IE 6 implements the box model mostly correctly in standards mode (IE 5 is another story, but I think we can forget about that one). IE 6 will occasionally double up padding for no apparent reason, though this seems to be an unrelated bug.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS