MEURSAULT MEURSAULT - 10 months ago 44
CSS Question

How do I right align div elements?

The body of my html document consists of 3 elements, a button, a form, and a canvas. I want the button and the form to be right aligned and the canvas to stay left aligned. The problem is when I try to align the first two elements, they no longer follow each other and instead are next to each other horizontally?, heres the code I have so far, I want the form to follow directly after the button on the right with no space in between.

<!DOCTYPE html>
<html lang = "en">
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="timeline.js"></script>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" />
<body bgcolor="000" TEXT="FFFFFF">
<div id="button">
<button onclick="showForm()" type="button" id="cTask">
Create Task
<div id="addEventForm">
<p><label>Customer name: <input></label></p>
<p><label>Telephone: <input type=tel></label></p>
<p><label>E-mail address: <input type=email></label></p>
<canvas id="myBoard" width="1000" height="600">
<p>Your browser doesn't support canvas.</p>

and heres my css as of now

#cTask {
#button {
#addEventForm {
border: 2px solid #003B62;
font-family: verdana;
background-color: #B5CFE0;
padding-left: 10px;

Answer Source

You can make a div that contains both the form & the button, then make the div float to the right by setting float: right;.