CSS minimum
November 23, 2007 3 comments
In this article, presenting a proposal for a minimum CSS file, that is, statements that, in my view, are essential to a style sheet.
Contents
What prompted me to write this article
In recent days, I had some problems with CSS files that had to change - and that I was not myself, originally, who did. Each developer has their style of Web coding, this is fact, another fact is that it becomes difficult to provide maintenance work on the outside, if the developers have not agreed standards for tagging one another. It was my case…
In this article, not try to make models of CSS coding, suggestions of how to position the keys, and how it should be the identação of texts. I am focusing on the rules, themselves, and not on how each one prefers to organize your code. To this end, the Bruno Dulcetti already handled very well in your blog.
How not want the same happens with other people, decided to bring in as would, in my opinion, not very extensive knowledge of CSS, some rules essential for any style sheet.
To appear, I would like to leave a recorded that the foundations of which I will present here was taken compilation of 70 Expert Ideas For Better CSS Coding, the Smashing Magazine - and translated by Maujor in your blog; another, comes from my own knowledge and experience with CSS.
Without more enrolações, to what we matter!
"Reset" the elements
To begin with, it is more important than clear, in the universal selector, margin and padding:
* (
margin: 0;
padding: 0;
)
[Update]
The Pedro Rogerio talked about a better way to reset the elements. Way to put that here, too.
[/ Update]
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, quote, code, del, dfn, in, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, I read, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td (margin: 0; padding: 0; border: 0; outline: 0; vertical-align: baseline; background: transparent; Body () line-height: 1;) ol, ul (list-style: none;) blockquote, q (quotes: none;): focus (outline: 0; ins) (text-decoration: none; del (text) - decoration: line-through;) table (border-collapse: collapse; border-spacing: 0;) They can only make sure that avoid at least a dozen problems with positioning - Eric Meyer, Christian Montoya and Roger Johansson, for example, recommend this practice.
A font-size "special" to html
The next - and apparently eccentric - step is to place a value "special" for font-size, the styling of html:
html (font-size: 100. 01%;) It came, too, from 70 tips, and the explanation is as follows:
This strange value of 100.01% for the font size, corrects a number of bugs in various browsers. First, define a size of the source element body as a percentage (instead of MS) prevents a problem in IE / Win that tends to disproportionately increase or decrease the size of sources for text contained within elements where size is set to source in MS . What's more, some versions of Opera renderizam default sizes from 100% to sources much smaller compared with other browsers. Safari in turn does not behave well with font-size equal to 101%.
Remove the edge of the ugly images that are link
When you place an image to serve as a link, a border appears to indicate that. However, it is very ugly and, in most cases, "breaking" the entire line of web design being used. To address this, simply reset the border of the element img:
(img border: 0;) The such "minimum CSS"
Then, the file end - or would be "original"? :-) - Would be as follows:
* (
margin: 0;
padding: 0;
)
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, quote, code, del, dfn, in, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, I read, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td (margin: 0; padding: 0; border: 0; outline: 0; vertical-align: baseline; background: transparent; Body () line-height: 1;) ol, ul (list-style: none;) blockquote, q (quotes: none;): focus (outline: 0; ins) (text-decoration: none; del (text) - decoration: line-through;) table (border-collapse: collapse; border-spacing: 0; html) (font-size: 100. 01%;) (img border: 0;) Finally…
These tips that I raised are mere "security measures" in order to avoid problems with estilizações. Certainly there are other more, because every day, a new technique and / or how to tag appears - and / or the technology itself is improved. Who know more tips, and macetes Trick for a minimum CSS, please, put a comment here or send email to me I can update the article.
Ah! And give the 70 tips for CSS, because they really are very good!









Great tutorial, congratulations!
I will use these tips in my next work.
;]
HUNT @ [COBRA]
Thank you!
As recommended in the post, be sure to give the 70 tips, there are many other techniques that fail to be "mandatory" but that, depending on the design and style of the developer, are of great use!
Apareça!
Pingback on February 26, 2008