A good rule in CSS is to never use the contents of an element to style the element itself. Unless you have absolute and total control over every tiny piece of your site, you can’t be sure that the necessary content will be there to aid in the styling of its parent. (And, if you insist that the content be there, then you’re doing something very odd indeed: you’re letting your CSS dictate the content of your site, and that’s certainly not the way to go.)
So, you see, it really is a bad idea to base an element’s style on the contents of that element in the browser . It is much better to find a way to style it directly.
Cascading order is one the fundamental features of the CSS specification. It determines how much “weight” is to be applied to a given CSS rule, based on the situation in which it appears. In essence, more specific CSS statements
overrule more general ones, and if two or more CSS statements with the same weight appear in a Web page, it is the last one that is applied. This is an over-simplification, but is a useful way to remember how things are supposed to work.
Let’s say we set up the .box style to be reliant on an h2 at the start, and a p tag at the end, applying a background-image to each one. Blogger.com has thousands of users, so what are the odds that every single one of them will always use those two elements in every “box” they create?
And if we get clever and say, okay, let’s not specify actual tags in our CSS, let’s use :first-child and :last-child, or let’s insert a .first and .last class in the XHTML, we’ll still run into problems. Not every browser understands :first-child and :last-child, and not every user will remember to insert .first and .last classes into their documents. Do they even know what classes are?
And finally, what happens if the box contains only one element? How can you apply two background images to a single element? You can’t.
Here are the actual cascading rules, presented in more detail:
Situation: A browser is presented with a number of CSS statements, some of which conflict with each other.
• If a statement is applied to a “parent” HTML tag (such as<BODY>) and tags that are its “children” have explicit CSS
statements of their own, the CSS statement that applies to theparent rules.
• The CSS statements are then sorted by explicit weight, and any marked !IMPORTANT (covered in the next section) take precedence over the others.
• Any style sheet information that may be imported through the <LINK> tag will be overruled any CSS statements contained within the Web page.
• More specific CSS statements overrule more general ones.
• If two or more CSS statements appear that have the same weight, the one specified last wins.
The generalization made earlier really applies only to the last two items presented here, but it is a good rule of thumb and can arguably be applied to the first three items in more general terms.
City of Asbury Park, boardwalk events, city restaurant and real estate news Asbury Park Life, the Asbury Boardwalk, and the City of Asbury Park …boardwalk events and city business, restaurants and real estate news in Asbury Park Life. Courtesy of Paul R Hauke and IFFPF Inc, free restaurant, business and real estate news. The latest on the Asbury Partners re-development, ...
Monopolize Your Marketplace with IFFPF Inc Increase Business by 30 - 120 % Separate your business from the competition. Learn the SECRETS to MONOPOLIZE YOUR MARKETPLACE (tm). Increase Business Revenue by 30 - 120 % or More in First Year. For business owners who want to consistently make at least $1, 000, 000 to $5, 000, 000 Profit per year, Monopolize ..
EZ AUTO DEALERS USA LOW LOW PRICES NEW USED CARS TRUCKS SUVs RVs New cars & used cars, SUVs & RVs sold and leased at dealer guaranteed low low prices from a nationwide inventory of over one million (1, 000, 000) vehicles from trusted car dealers through ezautodealers.com (tm), a dealer to consumer new & used car & truck & SUV ...
Digital Photography Cameras, Photographic Equipment Digital Photography Cameras of all famous World Brands.
Flash Templates - Best Flash website Templates On The Net! Flash templates is the best way to make a professional and good looking web site. At the same time it is faster and you dont have to hire an expensive web designer to make a perfect web site.
Sheet music : Lyrics and tabs We offer over 411.000 titles of Sheet Music!
Flash & html web design templates. Webmasters Selection Professional flash and html web design templates. Support and custom web design services provided.
Ecommerce Templates - Oscommerce Templates E-commerce / oscommerce templates are prepared so it is easy to insert your personal products and content. The major benefits of E-commerce templates compared to custom design are that you save a lot of time & money as the design and the store are already done.
Avslappning Swedish self hypnosis site
Flash Webdesign Med vores flash og html web skabeloner kan du få et professionelt webdesign, til en ekstremt lav pris, og samtidig spare en masse tid, da selve designet allerede er udarbejdet.
|