/    Sign up×
Community /Pin to ProfileBookmark

Hi guys,

I read yesterday, that there in CSS, all classes and ids should be defined using small characters. is this true?

does it mean that with i have a class myBoat it might not work in some browsers?

And another questions, is it better to name images like myBoat.jpg or myboat.jpg?

Thanks.

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJun 21.2006 — I read yesterday, that there in CSS, all classes and ids should be defined using small characters. is this true?[/QUOTE]Where did you read that, HTML Goodies? Just match the case used in the HTML but assume case insensitivity - don't assume that "myBoeat" and "myboat" are two different classes.

I prefer "my-boat".
Copy linkTweet thisAlerts:
@tigerasyaauthorJun 21.2006 — That's the thing..i don't remember where i read it...i might have been even at ths forum....but i'm not sure...
Copy linkTweet thisAlerts:
@felgallJun 21.2006 — Consistency is the key. If you use lowercase for all of your HTML and CSS (tag, class and id names) then you don't need to worry about whether a given browser will be case sensitive or not. You do need to use the correct capitalisation for the attributes assigned within the CSS.

XHTML is case sensitive, HTML is not.
Copy linkTweet thisAlerts:
@tigerasyaauthorJun 21.2006 — Thanks for your response, felgall. This information was more than helpful.

Thanks again.
Copy linkTweet thisAlerts:
@CharlesJun 21.2006 — However, a given browser might take XHTML to be HTML in which case myBoat will incorrectly be taken to be the same as myboat.
Copy linkTweet thisAlerts:
@WebJoelJun 22.2006 — W3C says "....it is recommended that the [I]mixed capitalization [/I] be used to make the names more legible", however, if [I]you[/I] mix the case incorrectly (inconsistantly), the rule will be ignored.

Therefore, #thisSection {} in the CSS won't be used if referanced in the HTML as <div id="ThisSection">~</div>

Personally, -I prefer using all lower-case letters, always. And if you use a semantic naming convention for your elements (e.g., #left_column, #right_column, #mainbodytext, #banner, #footer, etc.), it will 'make sence' later when you or someone else is reading or editing it because it was named intuitively.

Naming conventions like #this, #that, #nothisone, #andnowthis, are non-semantic and even though they match their HTML counterpart and would be correct, -they don't make intuitive sence at first glance and create the possibility of errors.

Lower case all the time works. ?
×

Success!

Help @tigerasya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...