I'm new to webdevelopment and want to abide to the 'standards' in the field. I've understood that the table tag is for tabular data and the div tag is used for layout (followed some heated debates on i-net here and there).
I'm trying to construct a layout of a view and I'm doing my best to use div. But how do you space the elements exactly right with divs? I used to do this with the table tag in a few seconds.
This is my layout now:
As you can see, it's not lined out nicely.
This is my Razor code:
@model WebHIS___ArtsPortaalWeb.Models.SearchPatientModel
@using (Html.BeginForm()) {
<div>
<div class="editor-label">
Voornaam:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.FirstName)</div>
<div class="editor-label">
Achternaam:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.LastName)</div>
<div class="editor-label">
GeboorteDatum:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.DateOfBirth, new {@class = "datafield", type = "date" })</div>
<div class="editor-label">
BSN:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.BSN)</div>
<div class="editor-label">
Straat:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.Street)</div>
<div class="editor-label">
Huisnummer:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.HouseNumber)</div>
<div class="editor-label">
Postcode:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.Zipcode)</div>
<div class="editor-label">
Plaats:</div>
<div class="editor-field">@Html.TextBoxFor(model => model.City)</div>
<input type="submit" value="Sumbit" />
</div>
}
My CSS:
.display-label,
.editor-label {
margin: 1em 0 0 0;
float: left;
}
.display-field,
.editor-field {
margin: 0.5em 0 0 0;
float: left;
}
Thank you in advance for helping.
UPDATE: Apparently my question was not clear. I want my layout to look like the image, but then with the textboxes neatly lined out. So the textbox of "voornaam" exactly lines out with the textbox of "straat". The labels can be aligned right, against the textboxes they correspond with. I hope I made my wish more clear.
` and list item `- ` elements? Seems the most logical choice semantically to me.
– Joshua Apr 08 '13 at 12:17