id css selector code example
Example 1: css class
.myclass {
border:1px solid black;
background-color: #d2d2d2;
height:20px;
width:60px;
}
/*If you give this class to a div in html, it will get the styles you gave
to that class. You can add multiple classes to a div, and multiple divs
can get that class. */
/* I hope I helped! */
Example 2: css id selector
#id{
color:red;
}
Example 3: how to call an id in css
<style>
#selector {
color: red;
}
/* # is id selector */
</style>
<div id="selector">
<p>This is an id</p>
</div>
Example 4: css how to style id
/*put a # infront of the id*/
/*<section id="example"></section>*/
#example{
margin: auto;
}
Example 5: css parent selector
/* There is no such selector
in 2008, the following was suggested */
a < img { 'border': none }
/* Which in theory, would set an an images 'a' parent
border to none
Of course, this does not exist
Another suggestion... */
div:parent { 'border': none }
/* Pretty self explainatory, nevertheless it does not
exist.
You will have to use JavaScript/jQuery */
$('some-element').parent();