Helpful Information
 
 
Category: CSS Help
CSS question

I'm trying to master the art of CSS, so I was examining a stylesheet. Most of it seems pretty obvious, but the are two things I don't get:
1. What does these lines mean:


.Content>p {margin:0px;}
.Content>p+p {text-indent:30px;}

2. What is the difference between a class and an id ?
For instance: <div id=menu> or <div class=menu>

Hope somebody can help me,

Thanks,

Ronald

An ID is a handle for that tag between it's opening and closing tags. Any JavaScript/CSS reference to that handle is applicable to the tags given that ID. A class on the other hand is defined inside the CSS style tags. A class is used when two or more items on a page display similar attributes (such as <p>, <h2> etc where you want all fonts to be black and 10pt and italic for example).

I don't know what the p and p+p means on the other bit. Never seen it before, but the .content is similar to having a.whiteLink where a is for the anchor tag and .whiteLink is the whiteLink class.

I've never seen any descriptors like that...seems like a typo.

Just to add to binky's explanation...

An ID is used for more than CSS, its a handle for that element in JavaScript as well. Its intended to be a unique identifier. If you give more than one element the same ID, the script associated with that element won't work. Of course you can assign CSS rules to it like this...
#id_name {position: absolute.....}

A class is only used in CSS and can be applied to any element, as many as you like....

.class_name {color: blue}
a.red {color: red}

CSS doesn't care if you define an ID or class the same way.

Happy Coding!










privacy (GDPR)