id selectors
id names are referenced in CSS as #idref
, and may or may not have an element name preceding the period (#idref
or element#idref
.
Example
3.6 - id selectors - Example 3.6
<header>
<h1>Lorem Ipsum </h1> </header>
<main><!-- main content -->
<section id="bigidea">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras sollicitudin, orci nec facilisis vehicula, neque urna porta risus, ut sagittis enim velit at orci. Fusce velit. Integer sapien enim, rhoncus vitae, cursus non, commodo vitae, felis. Nulla convallis ante sit amet urna. Maecenas condimentum hendrerit turpis. </section>
<section>Fusce velit. Integer sapien enim, rhoncus vitae, cursus non, commodo vitae, felis. Nulla convallis ante sit amet urna. </section> </main>
<footer>Maecenas condimentum hendrerit turpis. </footer>
In style
element
(<style>
) within head
element:
h1 { text-align: center; }
section { margin: 1rem; }
footer { margin: 1rem;
padding: 1rem;
border-top: thin solid black;
background-color: #f0f0f0;
}
#bigidea {
background-color: blue;
color: white;
border-color: green;
border-width: thick;
border-style: solid;
line-height: 1.5;
padding: 1rem;
}