turtle Posted December 9, 2007 Share Posted December 9, 2007 Hi,I'm new to CSS and wherever I looked I couldn't get an answer to my question. So here I am at the forums. Basically I'm wondering if the following is correct. #text{font-size:130%}#header{font-family:arial, verdana, "lucida console";font-weight:bold;font-size: 480%;text-align:center}.hello{font-size: 900%} As you can see I have no html tag on the id's or the class yet still they work. I checked a few validation websites and they said all was fine.In my html document I was using the id multiple times to define different sections with headers and text.So basically I'm asking can I use the following in the CSS code#*what ever i like* {CSS styles....}And in the html document put<div id="*what ever i like*>The bit of text </div>And can I do the same with classes doing this in the CSS.*what ever i like* {CSS styles.....}And in the html document put<div class="*what ever i like*>The bit of text</div>Is this ok to do ???Thanks for any help Link to comment Share on other sites More sharing options...
zppblood Posted December 9, 2007 Share Posted December 9, 2007 Make sure to put a closing " for the <div class"*whatever*>. Looks like you can use _, a-z, A-Z for the first character of the id/class and 0-9, A-Z, a-z, _ for any character after. CSS has a lot of ways to select certain elements.# is for id's. is for classesIf you don't specify what element to select such as h1.example { ... }, it will select all of the elements with that same class name, and that is what you did. Link to comment Share on other sites More sharing options...
MrAdam Posted December 10, 2007 Share Posted December 10, 2007 Yeah it's fine... but you shouldn't really use the same ID for more than one element as it's considered a 'unique id'. You may also run into problems with JavaScript doing that.Adam Link to comment Share on other sites More sharing options...
Synook Posted December 11, 2007 Share Posted December 11, 2007 It is invalid to have two elements with the same id. Also, if you have spaces in your class attribute you assign multiple classes to that element, e.g. <img class="class1 class2 class3" /> Link to comment Share on other sites More sharing options...
turtle Posted December 12, 2007 Author Share Posted December 12, 2007 Ah ok.Thanks a lot :)Answers my question perfectly Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.