CSS tips you must never forget

Written By :

Category :

fedora

,

General

,

guias

,

Linux

,

ubuntu

Posted On :

Share This :

css tips Should you use Tables or Divs? Is is better to use align or float? should I use a background image or color? There is something hiding behind everything in here… do a CSS is a mess! so you have to be really organized. This is not intent to be a CSS how to, is just a quick list of things you might find useful when you’re trying to create one, or at least, trying to force some changes in your html documents.

Class and ID

NEVER forget the difference between Class and ID… but if you do, don’t freak out, is as easy as change a # for a .
.Class #ID

Align images everywhere

When you’re trying to align an image inside a text, instead going with tricky tables just give it a float property and your problem will be solved (at least most of the times.). You should no apply any property to your text since the image is the one who has everything inside, in this case, image property is a style=”float:left;”
#class img { float: left; }

Make that div be centered

It’s kind of usual to see websites that have a fixed div for content and just stay centered even if the screen size is bigger. Make sure to add a margin 0 to your main div and solve it.
#class content { margin: auto; }

Rounded borders

I love to see rounded borders but I don’t like to use too many images for my websites, CSS make it faster. Even so, sometimes those damn borders work on firefox but stop working on Chrome (don’t even ask me for IE), so, make sure to add both lines.
#class { border: 5px solid #567924; -webkit-border-radius: 5px; -moz-border-radius: 5px; }

Remove underline at links

When comes to links, I rather to give them a different color and perhaps, add some bold style than just make them blue with that terrible underline. If you want to give them some style don’t forget to use text-decoration:
a { text-decoration: none; color: #234876; font-weight: bold; }