May 26, 2011

20+ Useful CSS3 and HTML5 Frameworks, Tools and Templates

I hope you have heard a little about CSS3 and HTML5. And I’m sure you’ve used at least one of the cool features they offer. But now it is time to use them at their full (or almost full) power.
You may be asking yourself “It is time to change? Should I forget everything I know and dive into this new world?”. Well dear padawan, you don’t need to do so. We have a lot of tools that make our transition to new and better technologies safer (ultimately we can’t just crash our customer’s website, we have bills to pay :D).
Frameworks are helpful with this. They’ve already been tried, tested and proven. Of course, you can always make them better, but they are a really good starting point.
This time we will talk a little about frameworks and other tools, like generators and templates.
So, let’s rock.

20+ Useful CSS3 and HTML5 Frameworks, Tools and Templates

HTML5 Boilerplate – Templating that fits all needs


This is the most useful for me. I usually have jobs that need easy setup, but a lot of optimizations tools (minifiers and more) and, at the same time, I’m quite familiar with CSS, so too much preset CSS is a waste of time to me (since I spend a few hours coding CSS, but much more to understand and re-utilize framework’s code).
Cool features:
  • Constantly improving – Last update says that they reduced the overall size of the published boilerplate by 50%
  • Build script – .js and .css minify, image optimization, html optimization, server configurations for caching…
  • Custom install setup – So you can choose what you want in “your” boilerplate
  • Cross-Browser compatible
  • HTML5 Ready
  • Print stylesheet ready to use

52framework – Supports almost anything


I am amazed by all the things you can do with this framework. It has a lot of resources that I thought would never work on IE. This is a good option when you want a somewhat styled template and  are planning to use almost all power of HTML5.
What do I like:
  • Almost anything you want with HTML – Local Storage, video player, canvas, forms…
  • A lot of CSS3 proprieties – As you can see in CSS demo, it has a good CSS3 support
  • Video Tutorials – Yeah, it makes even easier to understand 52′s workflow

G5 Framework – Good tools collection


Actually Greg Babula says that it meant to be just a personal project. But it is much powerful than he thinks.
As it was made from personal experience, it has a lot of tools that we already know how to use (Modernizr, CSS Reset, jQuery, Orbit Image Slider…), thus we don’t waste too much time learning.

Perkins – Lighweight and LESS


I must admit that I should use LESS much more than I do. If you think this way, Perkins may be a good option for you. It comes with a set of LESS stylesheets and mixins for common tasks such as creating navigation, rounded corners, gradients and much more.

Sprites.js – Animation framework (HTML5 support, of course)


Yeah, sometimes our customer wants some animations on their site. Why should you use flash when (almost every time) you can use HTML5?
Sprite.js provides a simple integration for canvas and HTML animations so you can do easily some animations, with maximum performance.

Lime.js – Gaming framework


Just take a look at the demo games, and tell me if it isn’t amazing.
Some features (HTML5) that you can use on it:
  • Optional install – For mobile users it is really good, just bookmark your game and you’re done
  • KeyFrame animations
  • Full support of sprite sheets
  • Stroke support – So you can draw a stroke around shapes
  • Good documentation – Just take a look at all classes you can use with it, pretty cool :D

HTML5 multimedia framework for WordPress


If you are a WordPress person, you will find it useful. With this plugin, you just have to add a shortcode and you have a HTML5 media player in your site.
The framework currently supports:
  • mp4 (h.264,aac)
  • ogg (theora,vorbis)
  • mp3 (audio only)
  • webm (vp8,vorbis).
  • wmv (via MediaElement.js)
  • flv (via MediaElement.js)
  • wma (via MediaElement.js)

Modernizr – HTML5 & CSS3 with fallbacks


Modernizr helps us to implement HTML5 and CSS3 for browsers that don’t natively support it. Actually many of the tools mentioned above use it.
Want to know more about its amazing features? Just read The All-In-One Entirely-Not-Alphabetical No-Bullshit Guide to HTML5 Fallbacks.
It is really simple to use, when modernizr detects your browser’s features, it adds classes to you HTML, so you can easily switch to a valid fallback. Try to run the demo and see its results for a better comprehension.

Select[ivizr] – CSS3 Selectors for IE


IE (6-8 mainly) is surely the greatest barrier to CSS3 spread. CSS3 selectors are almost forgotten for some developers, that just know they exist because can use them with jQuery.
You just need one of the 7 supported JavaScript libraries and you are ready to install it (via conditional comments, so just IE will see it). And then you’re done, just write you pretty CSS3 selectors as you aways wanted.

CSS3 button framework


With this framework you have easily a lot of good buttons options. It is specially useful for back-end developers, that aways need some pretty buttons, but don’t have time (or budget) to do so.
They are all CSS3 ready, and can be easily customized.

Templates – General HTML5 and CSS3 samples

Coming Soon Template


Design Company


Real State


Free HTML5 & CSS3 theme


Create An Elegant Website With HTML 5 And CSS3


Starter Pack


Much more inspiration at HTML5 Gallery


Some useful tools

CSS3 Button Maker


CSS Transforms code generator


CSS3 Gradient generator


CSS3 Drop Shadow Generator


CSS Generator for radius, shadows, rgba, @font-face, columns and more


The best @font-face generator I’ve ever seen


HTML5 Visual Cheat Sheet


Ready to start experimenting with HTML5?

You may notice that I didn’t even mention any mobile frameworks. It is because they are so cool that they deserve a dedicated post.
I certainly have missed some other good resources. Why don’t you comment and share what you know?

May 2, 2011

Do’s and Don’ts of Writing Better CSS and HTML

CSS and HTML are key languages to begin with, when you decide to invest your time in web design and development. They are powerful languages and most of the time may seem simple to work with.
However, every single one of us, beginners, or advanced developers, have committed basic or major mistakes working with both these languages. With this in mind, I believe it is extremely important and always welcome to learn some good tips and practices which I hope will help you improve your skills and experience.
Do’s and Don’ts of Writing Better CSS and HTML

Some of you may be thinking that since you don’t see anything out of place when viewing your web page, you have your HTML and CSS documents built correctly, but you may be wrong. The truth is that you should not trust everything you code. Using the same ID more than once on the same page won’t result in wrong alignments or retrieve any error (unless you try to validate), but it is in fact bad markup and a major flaw in your code.

Doctype

Doctype
Not so long ago, we had to use those really long Doctypes that were almost impossible to remember. Now, since you just need to use on the top of your document, we have a much cleaner and better solution. Nevertheless, some people still forgets to specify it. This is mandatory for a validated and organized HTML document.
How you should do it
Never forget your DOCTYPE.

ID vs Classes

ID vs Class
An ID is a unique identifier which allows us to target a specific element on the page and, since it is unique, it can only be used once in a page. On the other hand, we have classes which allow us to do exactly the opposite. Classes are used when you have the same element more than once on a page.
How not to do it:

1<div id="block">
2   <div id="btn">div>
3   <div id="btn">div>
4div>
How you should do it:
1<div id="block">
2   <div class="btn">div>
3   <div class="btn">div>
4div>

Say no to inline styling

Say no to inline styling
Inline styling is unfortunately a pretty common practice and at the same time a bad one. It has nothing to do with invalid code or bad markup, but with organized code and structure. Imagine you have 30 pages and you need to remove an inline style you have applied to the same div on every single page, it would take you forever and steal precious time.
How not to do it:

1<div style="width: 100%; background: #fff;">div>
How you should do it:
1<div id="wrap">div>

Ove use of divs and CSS Classes

Over use of divs and CSS classes
So you started your own project, you know how to use divs, ids, and classes. Inline styling is not your thing (fortunately), and you love to create styles and apply them everywhere. That’s great, but don’t write more than you have to. Having a div with an unordered list inside and a class applied to each li element is unnecessary.
How not to do it:

1<div id="navigation">
2   <ul>
3      <li class="left">li>
4      <li class="left">li>
5      <li class="left">li>
6   ul>
7div>
How you should do it
1<ul id="navigation">
2   <li>li>
3   <li>li>
4   <li>li>
5ul>
And in your stylesheet
1#navigation li { float: left; }

Browser Resolution

Browser Resolution
According to the W3c’s latest statistics (January 2011), 13.8% of internet users have a 1024×768 screen resolution, and 85.1% use a bigger screen resolution. So the question is “What resolution I should design for?” I personally use a maximum width of 960 or 980 pixels for a vertical layout and between 550 and 640 pixels in case of a horizontal layout. Besides, though 13.8% seems to be a fairly low number, it still represents millions of internet users.
How you should do it
Consider everyone’s needs, and especially your target audience.

Block vs Inline elements

Block vs Inline elements
Differentiating block from inline elements can be a a delicate matter for beginners. A block element is displayed on a new line taking by default 100% width of the containing element, like divs (
) or paragraphs (). An inline element is displayed with no line breaks meaning that it starts on the same line, taking only his own width, like span () or image (). You can also change the way an element is displayed, this means that you can change an inline element to be display as a block and vice versa.
How you should do it
1span { display: block; }

Use comments to organize your code

Comments
When I start a project, I try to organize it through commenting as much as possible and you should do the same. This is something purely optional but I highly recommend its use. It not only helps you find the section or element your are looking for, but also makes your life easier when you need to know which div your
is closing.
How you should do it
1
2<div id="header">
3
4div>
Stylesheet:
1/* --------------------------------------------------------------
2Header
3-------------------------------------------------------------- */
4#header { background: #fff; }

Cross-Browser Compatibility

Cross-Browser Compatibility
When you decide to make something, you should place yourself in the role of the end-user, and imagine that, even today, some of them still use browsers like IE6. A page in renders differently in Firefox than in Chrome or Internet Explorer. There are some useful tools you can use to check how your page renders in different browsers. Charina wrote a very complete article regarding this topic which I recommend reading – 10 Useful Tools For Cross-Browser Compatibility Check
How you should do it
Do not forget to pay attention to your layout in different browsers, systematically.

Keep it short – Generic classes, properties and CSS files

Keep it short - Generic Classes, properties, and CSS files.
When you are coding you should always have one thing in mind, plan for the future. You are already using comments and keeping your code organized, so why stop here? The first thing I do when I’m coding CSS is to specify a section of generic classes, then on my HTML I simply use them alongside with other elements.
How not to do it:

Stylesheet
1#firstblock { background: #000; float: left; }
2.genblock { background: #006699; float: left; }
HTML
1<div id="firstblock"
2<div class="genblock">div>
How you should do it
Stylesheet
1.left { float: left; }
2#firstblock { background: #000; }
3.genblock { background: #006699; }
HTML
1<div id="firstblock" class="left">div>
2 
3<div class="genblock  left">div>
This is a simple way of declaring two classes. I like to find the most efficient way to do things, and as you can already guess, I really like keeping things organized, so when it comes down to properties, it’s the same thing. Why should we write the same property over and over again when we just need to write it once?
How not to do it:

1#content { margin-top: 10px; margin-right: 12px; margin-bottom: 0; margin-left: 15px; background-color: #000; background-repeat: no-repeat; }
How you should do it:
1#content { margin: 10px 12px 0 15px; background: #000 no-repeat; }
The ideal number of CSS files you should have in your project depends entirely on you and the way you work. I have been involved in projects where there was a “generic.css”, “main.css”, “global.css” among others, it took me forever to understand the purpose of each file. I usually have just two CSS files on my projects – style.css and reset.css.
How you should do it
You should make it simple and efficient to edit later on.

Don’t use heading tags randomly

Don't use heading tags randomly
Heading tags are not just there to make it pretty, they establish the importance of your content which makes them valuable for SEO. There are six Heading tags: h1, h2, h3, h4, h5, and h6. H1 is the most important, so you should use it for your web page or business name only. The rest of the tags should be used according to title or content importance. Also, you don’t need to have heading tags everywhere on your document.
How not to do it:

1<h6>Post titleh6>
2 
3<h1>Text contenth1>
How you should do it:
1<h2>Post titleh2>
2<p>Text contentp>

Use absolute position only when you have to

Use absolute position only when you need to
When you’re starting out, you can easily become addicted to the use of absolute positioning. This is because it is an easy way of placing elements, however, this property should not be used excessively. Since elements with absolute position lose their normal flow, it is almost impossible to align them with other sections on the page. You simply can’t tell a normal element to be on the left side of an element with absolute position.

How you should do it:
Use absolute position only when you need to, and not because it is easier.

Type fonts

Type Fonts
So is there a font you really like and you would love to use it on your page, is it a standard font? What if not? These are are questions you need to ask before you choose your typography. When you choose a font you must always have a backup plan, this means that in case the user does not have the chosen font, the second choice (or third, etc) will appear. Examples of standard fonts are Arial, Georgia, Lucida Sans Code, Times New Roman, Verdana, Tahoma, and some more. Now let’s say you would like to use a font that is non-standard, what would you do? The most obvious answer is @font-face.
How not to do it:

1p { font-family: AurulentSansRegular, Arial, Helvetica, sans-serif; }
How you should do it:
1@font-face {
2 
3font-family: 'AurulentSansRegular';
4 
5src: url('AurulentSans-Regular-webfont.ttf') format('truetype');
6 
7}
8 
9p { font-family: 'AurulentSansRegular', Arial, Helvetica, sans-serif; }

Always validate

Always validate your code
The title is pretty self-explanatory, you should always validate your CSS and HTML documents. Why? The answer is why not? You have a way to know if your code has errors and it gives you solutions to fix them, so really, why not? Add CSS Validator and HTML Validator to your favourites.
How you should do it
Validate your CSS, and after that do the same for your HTML.

Conclusion

Some may consider these tips and techniques common sense and simple to understand, others not so much, but the important thing is that every coder make mistakes, and practice makes perfect.
Hope you enjoyed the article and have some fun experimenting, but keep it organized!