I have markup like this (can be modified if needed):
<div class="form-group">
<div class="form-element error">
<label for="from" class="form-label">From with a long label lorem ipsum dolor </label>
<input class="form-input" id="from">
<div class="form-error">A short error</div>
</div>
<div class="form-separator">-</div>
<div class="form-element error">
<label for="to" class="form-label">To</label>
<input class="form-input" id="to">
<div class="form-error">A long error lorem ipsum dolor sit amet consectetur adipiscing</div>
</div>
</div>
I want to achieve a layout like this:
where
- The inputs will be aligned regardless of how long the labels or error messages are
- The labels and error messages area aligned towards the input fields, there should be no space between them
- The separator is aligned with the inputs
I believe that what I need is CSS grid but I can't figure out whether a layout like this is possible. Or is this a case where I should use a table?