nshady Posted June 8, 2006 Share Posted June 8, 2006 Hi , I read a book and they mention bout <element id=name and <element class=nameid=name identifies a particular element while class=name identifies a particular classhuh ? what a particular class ? Element got class and individual ones ? Please guide me thanks. Link to comment Share on other sites More sharing options...
Err Posted June 8, 2006 Share Posted June 8, 2006 This link may help you. (Scroll down to center of page.) I'm sure if you do some more browsing around you'll find some other intresting answers. Link to comment Share on other sites More sharing options...
nshady Posted June 8, 2006 Author Share Posted June 8, 2006 This link may help you. (Scroll down to center of page.) I'm sure if you do some more browsing around you'll find some other intresting answers. <{POST_SNAPBACK}> I still do not understand diff between Class and ID hmm..but wat i mean was html not css ,mine was like<id=boyI am a boyAs for css , the name is was the value , but mine the name is in the content. Link to comment Share on other sites More sharing options...
boen_robot Posted June 8, 2006 Share Posted June 8, 2006 It's just that a class attribute is used to identify a particular group of elements. By using other languages (CSS most of the time), you can manipulate elements of the same class all at once.IDs are used when you need to manipulate only one certain element. IDs could also be used in the URL to link to the specific part of the page where that ID occurs. Link to comment Share on other sites More sharing options...
nshady Posted June 8, 2006 Author Share Posted June 8, 2006 I think im totally screwed up lol ....now i think i understand noneI think i should start with naming elements ? Please list notes for beginners huh. thnaks. Link to comment Share on other sites More sharing options...
scott100 Posted June 8, 2006 Share Posted June 8, 2006 This is an example of a class, the class is called .red and you can see that when i add this class to the <p> and <div> tags there contents are colored red. <html><head><style type="text/css">.red {color:red}</style></head><body><p class="red">This is a paragraph</p><div class="red">This is a paragraph</div></body></html> This is an example of id, notice how the <p> tag has id="red and the <div> tag has id="green". Then if you look in the <style> tag i can add styles to these tags by specifying a # in front of there id = #red + #green. <html><head><style type="text/css">#red {color:red}#green {color:green}</style></head><body><p id="red">This is a paragraph</p><div id="green">This is a paragraph</div></body></html> Does this make sense? Link to comment Share on other sites More sharing options...
nshady Posted June 8, 2006 Author Share Posted June 8, 2006 This is an example of a class, the class is called .red and you can see that when i add this class to the <p> and <div> tags there contents are colored red.<html><head><style type="text/css">.red {color:red}</style></head><body><p class="red">This is a paragraph</p><div class="red">This is a paragraph</div></body></html> This is an example of id, notice how the <p> tag has id="red and the <div> tag has id="green". Then if you look in the <style> tag i can add styles to these tags by specifying a # in front of there id = #red + #green. <html><head><style type="text/css">#red {color:red}#green {color:green}</style></head><body><p id="red">This is a paragraph</p><div id="green">This is a paragraph</div></body></html> Does this make sense? <{POST_SNAPBACK}> I think im beginning to understand , actually Id and Class have the same effect its just that ID can be used with 1 element rite ? Best to use one time.So better to use class rite ? What if i use class in every part , without using ID at all , issit okay ? Link to comment Share on other sites More sharing options...
snowboard01 Posted June 8, 2006 Share Posted June 8, 2006 Exactly Link to comment Share on other sites More sharing options...
nshady Posted June 8, 2006 Author Share Posted June 8, 2006 so i can omit id ? i use class in every single document But ID can be used a lot of times rite ? It's just that it cannot use da same NameLike <p id=orange>so the next 1 like <div id=(cannot orange anymore)as for class u can use same for both with different elements rite ? Link to comment Share on other sites More sharing options...
scott100 Posted June 8, 2006 Share Posted June 8, 2006 What if i use class in every part , without using ID at all , issit okay ?Yes that's fine, that's what makes css so powerful, you can give tags the same class and if you later decide you want to style that class differently all you have to do is make one change and all elements will change. Link to comment Share on other sites More sharing options...
nshady Posted June 8, 2006 Author Share Posted June 8, 2006 oops edited , reenter my questionsBut ID can be used a lot of times rite ? It's just that it cannot use da same NameLike <p id=orange>so the next 1 like <div id=(cannot orange anymore)as for class u can use same for both with different elements rite ? Link to comment Share on other sites More sharing options...
boen_robot Posted June 8, 2006 Share Posted June 8, 2006 But ID can be used a lot of times rite ? It's just that it cannot use da same NameLike <p id=orange>so the next 1 like <div id=(cannot orange anymore)as for class u can use same for both with different elements rite ? Yes. That's exactly what we meant. Just remember to put quotes though:<p id="orange">And before you ask (others asking this have): you think up of the class and/or IDs name. There are no predefined values. Orange could as well be "navigation", "link", "right", etc. or anything you come up with. Link to comment Share on other sites More sharing options...
scott100 Posted June 8, 2006 Share Posted June 8, 2006 But ID can be used a lot of times rite ? It's just that it cannot use da same NameLike <p id=orange>so the next 1 like <div id=(cannot orange anymore)as for class u can use same for both with different elements rite ?Yes your getting it, so if you wanted to use the same styles for more than one id you would seperate them with a comma.This means if you wanted the color to be orange you make one change and both id's change, saving you time.<html><head><style type="text/css">#redPara, #redDiv{color:red}</style></head><body><p id="redPara">This is a paragraph</p><div id="redDiv">This is a paragraph</div></body></html> Css is quite flexible, you can achieve the same things differently Link to comment Share on other sites More sharing options...
reportingsjr Posted June 8, 2006 Share Posted June 8, 2006 Isnt id also for browser scripting, like javascript so it can identify a block of code? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2006 Share Posted June 8, 2006 ID can be used in Javascript to refer to a specific element. That's another reason why you only want 1 element with any given ID (although CSS will still style 10 elements with the same ID).You can also give one element multiple classes. .red {color: red;}.uline {text-decoration: underline;}.floating {position: absolute; top: 150px; left: 100px;}<div class="red uline floating">...</div> Link to comment Share on other sites More sharing options...
smiles Posted June 10, 2006 Share Posted June 10, 2006 huh ? what a particular class ? Element got class and individual ones ? Please guide me thanks.<{POST_SNAPBACK}> class got elements as many as you like element can't have got class unless it is the one only in this class Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now