Jump to content
kermitsumoto

. Needed For Classes?

Recommended Posts

Hey guys.So i'm a bit green with css but im getting my game up. I recently came across a style sheet that had a class name without a '.' in front that works when loadedie:classname {height: 200px;width:200px;}I know by now id s get # and classes get . so how does this still work without the . ?

Share this post


Link to post
Share on other sites
Hey guys.So i'm a bit green with css but im getting my game up. I recently came across a style sheet that had a class name without a '.' in front that works when loadedie:classname {height: 200px;width:200px;}I know by now id s get # and classes get . so how does this still work without the . ?
It's not working, it simply can't be working.If you omit the '.', the browser will search for <classname> elements rather than elements with class="classname"

Share this post


Link to post
Share on other sites

Perhaps a custom doctype with unique syntax?

Share this post


Link to post
Share on other sites
It's not working, it simply can't be working.If you omit the '.', the browser will search for <classname> elements rather than elements with class="classname"
My only way of realizing this was working is when i removed that class without the '.' it no longer produced the result it was producing (background image).Maybe im not looking far enough into this but it just seemed weird to me. removing the class from the css completley was my only way to see that it was working. I thought it was garbage code til i removed it and it no longer displayed bg image

Share this post


Link to post
Share on other sites
My only way of realizing this was working is when i removed that class without the '.' it no longer produced the result it was producing (background image).Maybe im not looking far enough into this but it just seemed weird to me. removing the class from the css completley was my only way to see that it was working. I thought it was garbage code til i removed it and it no longer displayed bg image
Your original stylesheet might have been saved in the browser cache and that's why it still worked.

Share this post


Link to post
Share on other sites
Your original stylesheet might have been saved in the browser cache and that's why it still worked.
it actually removes the background right in dreamweaver. It s pretty weird. thats why im even talking about it.here's a look at the css http://www.cookieconfidential.com/cc.cssplease don't hate on the code format:(notice how "body" has no . in front of it. (theres an id and a class called body also but that shouldnt have anything to do with this, right?) This was something i overlooked and it was working then i said hey, why does that work, lemme add . or take that whole class out and see what happens? it lost the background image when i did that meaning it does use it.just weird to me

Share this post


Link to post
Share on other sites
it actually removes the background right in dreamweaver. It s pretty weird. thats why im even talking about it.here's a look at the css http://www.cookieconfidential.com/cc.cssplease don't hate on the code format:(notice how "body" has no . in front of it. (theres an id and a class called body also but that shouldnt have anything to do with this, right?) This was something i overlooked and it was working then i said hey, why does that work, lemme add . or take that whole class out and see what happens? it lost the background image when i did that meaning it does use it.just weird to me
Selectors such as body, p, h1, ul, don't need the full stop preceeding it. If you have .p then you would be declaring your own class of p.The .body is a declaration of a class.Strangely they're not reserved words or letters it seems and are happily validated.

Share this post


Link to post
Share on other sites

body is a required element of a correctly validating website I believe. Your site would end up having problems putting a . or a # in front of it. (similar to a reserved word...?)edit: nm, read above post instead of mine.

Edited by thescientist

Share this post


Link to post
Share on other sites
body is a required element of a correctly validating website I believe. Your site would end up having problems putting a . or a # in front of it. (similar to a reserved word...?)edit: nm, read above post instead of mine.
Well it all becomes clear to me now!ok, i did know that about p ul and all the text stuff but not "body"thanks for filling me in!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...