Implementation (CSS)Float (left, right)

Learn about how Cascading Style Sheets (CSS) can be used to style web pages.

Part ofComputing ScienceWeb design and development

Float (left, right)

An element can be set to the left or right of its container, we do this by using the float property.

An example of floating text, where text can be sent to the right or left.
<html>
<head>
<style>
p.example {float:right}
</style>
</head>
<body>
<h1>float example</h1>
When we use float, we can send things to the left or right.
<p class="example">This text should be on the right</p>
</body>
</html>

If we wanted to change the text to float to the left, we would have to change p.example{float:right} to p.example{float:left}.