css selector *[id=""] code example
Example 1: css class and id selector
Select an element with the ID "id" and the class "class":
#id.class {
}
example:
<div>
<strong id="id" class="class">
Foobar
</strong>
<strong class="class">
Foobar
</strong>
</div>
=> Will select the first <strong> element
Select all elements with the class "class",
which are decendents of a element with an ID of "id":
#id .class {
}
example:
<div id="id">
<strong class="class">Foobar</strong>
</div>
=> Will select the <strong> element
Example 2: css id
<style>
#your_id{
color: blue;
font-size: 24px;
}
</style>
<h1 id="your_id">Example text</h1>
Example 3: css class
.myclass {
border:1px solid black;
background-color: #d2d2d2;
height:20px;
width:60px;
}
Example 4: css id selector
#id{
color:red;
}
Example 5: how to call an id in css
<style>
#selector {
color: red;
}
</style>
<div id="selector">
<p>This is an id</p>
</div>
Example 6: css how to style id
#example{
margin: auto;
}