<style>
html {
background-color: goldenRod;
}
h1 {
background-color: #cccfdb;
color: mediumSeaGreen;
}
</style>
<h1>
Example content
</h1>
background-color:
sets the background color.
color:
sets the color of text.
<style>
section {
font-family: cursive;
font-weight: bold;
font-size: 32px;
}
</style>
<p>Default content
<h1>
Example content
</h1>
font-family:
sets the generic font family.
e.g. values: cursive, fantasy, monospace, sans-serif, serif
font-weight:
sets font weight.
e.g. values: bold, normal
font-size:
sets font size.
e.g. values: 6px, 12px, 24px, 48px, 96px
<style>
a {
text-decoration: underline;
}
a:hover {
font-size: 50px;
}
a:visited {
color: green;
}
</style>
<a href="#">Click me!</a>
text-decoration:
set the text decoration.
e.g. values: underline, line-through, overline, none
:hover:
adds a rule that styles elements the user hovers over.
:visited: adds a rule that styles elements the user hovers over.
<style>
img {
width: 80px;
height: 80px;
border-color: pink;
border-style: solid;
border-width: 10px;
}
</style>
Picture of Super Cutey<br>
<img src="/images/daughter1.jpg">
height:
width:
sets width of an element.
border-width:
sets the width of a border.
e.g. values: 0, 5px, 10px, 20px, 40px
border-color
sets the color of a border.
e.g. values: pink, red, orange, blue, green
border-style:
sets the style of a border.
e.g. values: solid, ridge, inset, outset, dotted, dashed, double, groove, none
<style>
img {
border-top: 5px solid orange;
border-right: 2px dashed darkRed;
border-bottom: 10px dotted brown;
border-left: none;
}
section {
border: 5px solid saddleBrown;
}
</style>
<section>
Picture of Super Cutey<br>
<img src="/images/daughter7.jpg"
width="100" alt="My daughter">
</section>
border:
adds a border with properties.
border-top:
adds a border to the top of an element.
border-right:
adds a border to the right of an element.
border-bottom:
adds a border to the bottom of an element.
border-left:
adds a border to the left of an element.
<style>
img {
margin: 0;
width: 50px;
}
section {
background-color: yellow;
margin-top: 0;
margin-right: 5px;
margin-bottom: 20px;
margin-left: 10px;
}
</style>
<img src="/images/daughter10.jpg">
<img src="/images/daughter5.jpg">
<section>Example content 1</section>
<section>Example content 2</section>
margin:
adds space around the outside of an element. margin is shorthand for setting margin-top, margin-right, margin-bottom and margin-left
Example values: 0, 10px, 20px, 40px, 20px 40px, 5px 10px 20px 40px
<style>
section {
box-shadow: 2px 4px gray;
border: 1px solid red;
padding: 40px;
}
a{
font-size: 28px;
font-weight: bold;
text-shadow: 0 3px 2px navy;
}
</style>
<section>
<a href"#">Example content. </a>
</section>
box-shadow:
2px 4px gray, -1px -1px 6px aqua, 0 0 4px 1px green, inset 2px 2px 2px blue
text-shadow:
adds a shadow to text. The order of the values is offset x, offset y, blur, color. Color can be first or last.
e.g. values: 0 3px 0 gray 2px -2px 0 red 0 0 3px green -1px 2px 3px blue
<style>
html {
background: hotPink url(/images/textures/light2a.png);
}
ul {
background-image: url(/images/textures/light7a.png);
background-color: yellow;
list-style-image: url(/images/silverStar.png);
}
ol{
list-style-type: lower-alpha;
}
</style>
<ul>
<li>List item 1
<li>List item 2
<li>List item 3
</ul>
<ol>
<li>List item 1
<li>List item 2
<li>List item 3
</ol>
background-image:
sets the background image.
background:
is a shorthand for setting background image and background color.
list-style-type:
sets the style of the list bullet point.
e.g. values: circle, disc, square, none
list-style-image
sets the image of the list bullet point.
<style>
section {
text-align: center;
}
h4{
text-align:right;
}
</style>
<h4>This example text is to the right</h4>
<section>
This example text is centered
</section>
text-align.
set the text alignment.
e.g. values: left, right, center, justify