Basically, I want to know what is best to avoid future problems and confusions with CSS code…
Naming CSS proprieties like this:
div#content
ul#navigation
div.float-left
(It’s really unnecessary to do this?)
or just
#content
#navigation
.float-left
I don’t have experience with big projects so I wish someone could tell me which method is better to use while the HTML and CSS get longer.
It depends what you want to happen.
will apply to everything with id=”content”, but
will only apply to a <div> with id=”content”.
This is usually more of an issue with classes since IDs should be unique across all elements on a page.
So the bottom line is, if you know the style information will only apply to HTML elements of a certain type, then include the element tag. This can stop styles from being unexpectedly applied to different elements with the same class (or ID, but that’s naughty).