August 31, 200817 yr Hey so I've got a question I think I should know but don't know. For example sometimes I see things like this: .header { background-color: #000000; { And some like this: #header { background-color: #000000; } Notice the "." and the "#" What is the difference if you denote it with a period or ampersand? Thanks, Meshach
August 31, 200817 yr The period/full stop selects by class, the hash (not ampersand) selects by id. For example: #header { background-color: #000000; } .headertext { color: #ffffff; } <div id="header"> <p class="headertext">Sometext</p> </div> A completely unsemantic example, however you can see the div has an id, and the p has a class, and which selector corresponds to which. id's are usually used for structural sections/elements like header etc, where as classes are used to differentiate between different styles within those sections, or styles which appear in more than one section. P.S. Hex color values must also be proceeded by a hash "#" so it should be: #header { background-color: #000000; }
August 31, 200817 yr P.S. Hex color values must also be proceeded by a hash "#" And if you're on a Macbook (with no hash key) - use Alt + 3. There's probably an easier way that I haven't discovered though.
August 31, 200817 yr Author The period/full stop selects by class, the hash (not ampersand) selects by id. For example: #header { background-color: #000000; } .headertext { color: #ffffff; } <div id="header"> <p class="headertext">Sometext</p> </div> A completely unsemantic example, however you can see the div has an id, and the p has a class, and which selector corresponds to which. id's are usually used for structural sections/elements like header etc, where as classes are used to differentiate between different styles within those sections, or styles which appear in more than one section. P.S. Hex color values must also be proceeded by a hash "#" so it should be: #header { background-color: #000000; } Okay. Thank you, I think I understand now. . . And if you're on a Macbook (with no hash key) - use Alt + 3. There's probably an easier way that I haven't discovered though. I'm using a windows, I mistakingly left out the hash... Sorry.
August 31, 200817 yr Mac's don't have a # key? I thought they were meant to be good! Not on my Macbook Pro (laptop) because it's a condensed keyboard. It might also be a UK thing, because we don't use the # to indicate a number. On the current USB keyboards they do.
September 1, 200817 yr My Mac Book doesn't have a '#' either. As you said it's probably because it's a condensed keyboard.
September 1, 200817 yr Whether you have a hash key or not probably depends on the country you are in as American and English keyboards vary.
Create an account or sign in to comment