Alignment refers to the position or placement of content, relative to the web page's other content.
At the bottom of this page there is a code editor pre-loaded with the lesson's code.You can use CSS to position text.
h1 {
text-align: center;
}
➼ h1
- This CSS block is gor all h1 elements
➼ text-align
- The text will be centered.
<h1>Bug Fighting Supplies</h1>
You can use CSS to describe how you want an element postioned.
.imgClass {
position: relative;
left: 250px;
max-width: 300px;
}
The float property describes elements that should be placed on a specified side of the outside container. Text and Inline Elements will wrap around the floating container.
img.right {
float: right;
max-width: 300px;
}
➼ float
- The im age will be positioned on the right side of itss container.
➼ max-width
- Regardless of screen size, the image will not be wider than 300px. It cn be sized smaller on smaller screens.
To avoid other elements wrapping around your floating element, use the clear property.
div {
clear: left;
}