background preloader

10 Best CSS Practices to Improve Your Code

10 Best CSS Practices to Improve Your Code
It’s really easy to find yourself wondering how your CSS got to be such a mess. Sometimes it’s the result of sloppy coding from the start, sometimes it’s because of multiple hacks and changes over time. Whatever the cause, it doesn’t have to be that way. Writing clean, super-manageable CSS is simple when you start off on the right foot and make your code easier to maintain and edit later on. Here are 11 tips for speeding up the process, writing CSS that is slimmer, faster and less likely to give you a headache. 1. Just like anything else, it pays to keep yourself organized. It will help you keep the cascading part of CSS in mind and sets your style sheet up to take advantage of style inheritance. Declare your most generic items first, then the not-so-generic and so on. Use a structure that works best for you while keeping future edits and other developers in mind. Resets and overridesLinks and typeMain layoutSecondary layout structuresForm elementsMiscellaneous 2. 3. 4. 5. 6. This: 7. 8. 9.

11 iPhone apps esenciales para diseñadores Si sois diseñadores y tenéis un iPhone, muchas veces habréis pensado que aplicaciones son las mejores para diseño y desarrollo web. Para no tener que irlas buscando por App Store, aquí os mostramos una excelente recopilación de aplicaciones para iPhone sobre diseño web y desarrollo que ayudará a más de uno y le ahorrará tiempo: 1. 2. 3. 4. 5. 6. 7. Igual que os presentamos una recopilación de referencias CSS, aquí tenéis la aplicación para iPhone. 8. 9. 10. 11. Vía | Designer-Daily

A Problem With Using “overflow: hidden” to Clear Floats The other day, someone asked me the following question: If I understand it right clear float is automatic in most modern browsers right? If you’re new to CSS, then it would seem that the answer to this question should be “yes, of course — modern browsers don’t have these types of bugs!” But the necessity to clear floats is not a browser bug; it’s actually, well, more of a CSS feature. This doesn’t mean, though, that clearing floats will always be necessary. But clearing floats are a fact of developer lives today, and so I thought I’d explain why clearing them is still necessary, even in “modern” browsers. What Does a Float Do? Here is, in part, how the W3C spec explains what floats do: Content flows down the right side of a left-floated box and down the left side of a right-floated box … Since a float is not in the flow, non-positioned block boxes created before and after the float box flow vertically as if the float didn’t exist. You can see this behaviour demonstrated in the JS Bin below:

Design A Fresh Blog Theme On The 960 Grid | My Ink Blog CSS Frameworks Up until a couple of weeks ago I never really understood the fascination with using CSS frameworks in web design. They just seemed very limiting and boring. If you have been hesitant to give CSS frameworks a try for similar reasons, I suggest you at least give them a fair shake before you write them off completely. Introduction In this tutorial I’ll show you how to mock up a fresh looking blog theme in Photoshop that is designed to be used within the 960 framework. The Files In order to help you follow along and learn the techniques in more depth, below is the PSD file and a full size preview. Step 1 In some of my past Photoshop mockups and noticeably so for this project, Photoshop has a tendency to fade out colors like they’ve been through the wash too many times. We are going to use the 960 photoshop template that is provided in the download. Step 2 For now, hide the visibility on the grid by clicking on the eye icon in the layers palette for the 16 Col Grid group. Step 3

Book - Scalable and Modular Architecture for CSS Every project needs some organization. Throwing every new style you create onto the end of a single file would make finding things more difficult and would be very confusing for anybody else working on the project. Of course, you likely have some organization in place already. Hopefully, what you read among these pages will highlight what works with your existing process and, if I’m lucky, you will see new ways in which you can improve your process. How do you decide whether to use ID selectors, or class selectors, or any number of selectors that are at your disposal? At the very core of SMACSS is categorization. There are five types of categories: Base Layout Module State Theme We often find ourselves mixing styles across each of these categories. Each category has certain guidelines that apply to it. Much of the purpose of categorizing things is to codify patterns—things that repeat themselves within our design. Base rules are the defaults. Examples of Base Styles Example classes

Free CSS Drop-Down Menu Framework - LWIS.NET Description Free CSS Drop-Down Menu Framework was first released back in June, 2008. Since then it has struck the audiences with its perfect cross browser performance and wide variety of drop-down menu transformations and themes. Modular, with themes. Frequently Asked Questions Q.Why are you using CSS property visibility and not display in order to reveal and hide drop-down menus? In my tests some versions of IE7 did not handle display property correctly. Now you will be able to manipulate your drop-downs with JavaScript (use animations, etc.). Q.How do I center the menu horizontally? There is no reliable cross browser solution to center those floating menu items. Please refer to the two available demo templates illustrating horizontal menu centering - MTV.com and Adobe themes. Q.I have a flash object below my drop-down menu and those drop-downs appear behind the flash. You must use wmode attribute within your object and embed tags of your flash element. A.Yes, it does work on such OSes.

Contenuti generati, numerazione automatica ed elenchi In alcuni casi, gli autori possono volere che i programmi utente rendano del contenuto che non proviene dall'albero del documento. Un esempio comune in tal senso è un elenco [list, anche "lista"] numerato; l'autore non vuole elencare i numeri esplicitamente, ma lui o lei vuole che il programma utente li generi automaticamente. Similarmente, gli autori possono volere che il programma utente inserisca la parola "Figura" prima della didascalia di una figura, o "Capitolo 7" prima del titolo del settimo capitolo. In particolare per l'audio o il braille, i programmi utente dovrebbero essere in grado di inserire queste stringhe. Nei CSS2, il contenuto può essere generato da diversi meccanismi: La proprietà 'content', in unione con gli pseudo-elementi :before e :after. Di seguito descriviamo i meccanismi associati con la proprietà 'content'. 12.1 Gli pseudo-elementi :before e :after Gli autori specificano lo stile e la locazione dei contenuti generati con gli pseudo-elementi :before e :after. none

[Ask SM: CSS] Equal Spacing, CSS Font Replacement | CSS Advertisement This is our fourth installment of Ask SM, featuring reader questions about Web design, focusing on HTML, CSS and JavaScript. In this post we’ll cover how you can distribute the horizontal space between elements evenly, how you can achieve maximum sides on images; you’ll also learn best practices for CSS font replacement and answers to a couple of quickfire questions. If you have a question about CSS or JavaScript, feel free to reach me (Chris Coyier) via one of these methods: Send an email to ask [at] smashingmagazine [dot] com with your question.Post your question in our forum.Or, if you have a quick question, just tweet us @smashingmag or @chriscoyier. Please note: I will do what I can to answer questions, but I will certainly not be able to answer all of them. Distributing the horizontal space between elements evenly Antoine Nicolas writes: Do you know how to perfectly and dynamically distribute objects horizontally in a container using CSS? Let’s review the specific goals:

CSS 2.1 selectors, Part 2 This is the second part of a three-part article series that explains the selectors that are available in CSS 2.1. Part 1 is about the more basic stuff like type selectors, class and id selectors, the universal selector, and simple selectors. In this part I will take a closer look at the more advanced selectors, not all of which are yet fully supported in all major browsers. Support is getting better though, so learning about the selectors that are described in this article is time well spent. Combinators Combinators are used to separate the two or more simple selectors that make up a combined selector. Descendant selectors A descendant selector is made up of two or more simple selectors separated by whitespace. Each of the selectors that form a descendant selector can be a simple selector of any form. Descendant selectors allow you to target elements without giving them a class name or an id, which in turn helps keep your markup clean. Child selectors Adjacent sibling selectors Grouping [att]

CSS Differences in Internet Explorer 6, 7 and 8 « Smashing Magazine Advertisement One of the most bizarre statistical facts in relation to browser use has to be the virtual widespread numbers that currently exist in the use of Internet Explorer versions 6, 7 and 8. As of this writing, Internet Explorer holds about a 65% market share combined across all their currently used browsers. The interesting part of those statistics is that the numbers across IE6, IE7, and IE8 are very close, preventing a single Microsoft browser from dominating browser stats — contrary to what has been the trend in the past. Thanks to the many available JavaScript libraries, JavaScript testing across different browsers has become as close to perfect as the current situation will allow. This article will attempt to provide an exhaustive, easy-to-use reference for developers desiring to know the differences in CSS support for IE6, IE7 and IE8. This article does not discuss: Any item that is not supported by any of the three browser versionsProprietary or vendor-specific CSS Example

CSS Message Box collection Message boxes are useful elements to display status messages after or during a specific user request. Some days ago I wrote this post about how to implement a nice Ajax chains of effects (fade in, delay, fade out) for a common message box using mootools. Today I want to share with you a collection of some simple CSS styles you can apply to your message boxes (clean, solid, iconized, alternated rounded borders, tooltip). I added also a link to download a beautiful icon pack to use in your projects to design custom message box or other graphic elements. Download message box collection source code Clean message box I love clean and simple design and in general this is my preferred message box style: a border (1px) and a light background color: HTML code is very simple: <div class="clean-gray">Clean message box</div> ...a DIV layer with with some text within. .clean-gray{ border:solid 1px #DEDEDE; background:#EFEFEF;color:#222222;padding:4px;text-align:center; ...and the related CSS code is:

Ordenación del CSS Ordenación del CSS 19 feb aNieto2k hace 1880 días en: CSS, Programacion, webdev Recuerdo que hace ya mucho tiempo hablamos con Daniel Mota sobre la cantidad de comentarios en nuestros CSS, pero aún podemos ser más meticulosos con estos ficheros. En Aloe Studio han dividido las propiedades en una serie de secciones (bastánte obvias) que engloban las propiedades ordenadas: Display y flujoPosiciónDimensionesMargenes, Padding, Border,…TipografíaBackgroundOpacidad,Cursores,… De esta forma obtenemos un listado de propiedades ordenadas como esta: Al igual que en el artículo, nunca me ha gustado ordenar las propiedades CSS alfabéticamente, no le encontraba lógica a definir antes el border: antes que la posición. ¿Y tu? Actualización Para complementar la lectura, recomiendo echarle un vistazo a las buenas maneras propuestas por Deziner Folio, son bastánte obvias pero importantes de conocer.

Related: