Jump to content

CSS format i html tag


jum

Recommended Posts

I see many examples on the web where the html tag by CSS has got a background image instead of doing it in the body tag. I also have seen notices that CSS formatting should not be used on the html tag at all. Furthermore I have noticed that at least Chrome, Firefox and Internet Explorer supports background images in the html tag. I have had much difficulty searching for it as "CSS" and "html" is all-over-the-place. What is correct? What is recommendable?

Link to comment
Share on other sites

Guest LH91325

With the STRONG exception of "frames" and "FRAMESET" etc. (which is IMO an incredibly outmoded concept, a relic from before there was CSS), there is nothing displayable that I can think of that would come under the scope of your HTML tag that isn't also inside the scope of your BODY tag. I can't think of anything you could style from your HTML tag that couldn't more easily and simply be styled from your BODY tag. Also you have some chicken before egg or egg before chicken problems unless you're going to apply your style inline directly to your HTML tag. I mean style applied from within any HTML tag is again kind of outmoded, perverts the concept of CSS in the favor of blunt application of style in a manner that is hardly better than direct HTML formatting tags. In other words, you can't apply a style from a named CSS file or from STYLE and /STYLE tags within your HEAD /HEAD area yet because the HTML tag is the first thing the browser sees, other than !DOCTYPE stuff is the HTML tag and the browser hasn't had time to read style declared in the HEAD section either directly or via indirect through CSS file reference. So I don't understand what style you could apply to your HTML tag that couldn't more easily be applied to your BODY tag. You should give that some thought. This is my first visit to the W3S forums in years and I doubt I'll be here to read your reply (if any) but I hope I've helped to answer what I feel is an elementary CSS question. IMO any styling you want to apply to your entire document should be applied to your BODY tag. That is a well established technique with plenty of examples on production (professional) websites. Your best method to apply this is by embedding your CSS within your HEAD section or indirectly by reference to a CSS stylesheet from within your HEAD section, and then apply the style to your BODY tag.

Link to comment
Share on other sites

Guest LH91325

Well I've been giving this more thought and perhaps my answer is wrong. I've been looking at some professionally operated sites and reading their source and found this:

<!DOCTYPE html><!--[if lt IE 7]> <html class="no-js ie6 ie" lang="en"> <![endif]--><!--[if IE 7]>	<html class="no-js ie7 ie" lang="en"> <![endif]--><!--[if IE 8]>	<html class="no-js ie8 ie" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> ...

So in a way it makes sense, I can see what they're doing. I have absolutely no idea if there's a better way to accomplish that. It seems to me that it could equally be applied to the body tag but I'm not any kind of an expert.

Link to comment
Share on other sites

I read something a long time ago to use html and body together if you're gonna change spacings like margins and padding. It's probably outdated but when I'm changing the entire page, I will, even today use

html, body {...}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...