I have a table with a label in column 1 and an input field in column 2.
<table>
<tr>
<td>Title</td>
<td><input type="text" name="title" value="My Title" /></td>
</tr>
</table>
The input field text appears smaller than the label text. Fiddle. I assume this is because the input field takes space which seems to cause the input text to be smaller to fit within the remaining space?
What I want is for the input text to always be the same font size as the label text, expanding the row height if needed to accommodate. How to do this generically on table rows with various input fields?
2
Answers
Just add font-size property to the input element with the same size of your font.
And you are good to go
Either use CSS to set font properties, like
font
,font-family
,font-size
,color
, etc. specifically or have those propertiesinherit
the values set by a (ancestor) parent element. Essentially like you did in your Fiddle.Because:
Most, if not all HTML
<input type="...">
elements, as well as a few others like<select>
and<option>
,<label>
have default markup values set by the User Agent (browser) to make them closely resemble the respective widgets used by the Operating System of your device (PC/smartphone) outside the browser.Think of default:
You can easily override fonts and graphics in your CSS, but changing behavior often requires the introduction of Javascript to ‘catch’ default actions and replace them with your own (usually some ‘Observer’ or ‘eventlistener’). A next step in the wondrous world of web design…