I have been trying to apply one white space inside the span element, but couldn't able to do it.
In my application i have the following two span elements.
<span style='color:red;margin-right:1.25em'>*</span>
<span style='color:red;margin-right:1.25em'> </span>
Applied these two spans to different fields to get them in to the same alignment level, but i have the following problem. PFB
is there any thing wrong with the above code
the first name field should move a bit right for the proper alignment.
Try: margin: 10px or similar in the span styles. That gives you a space. If you need more than one whitespace, you can use entity.
Since span tags are inline, not block elements. They can only take margin left and right, not top and bottom.
The main thing to remember about a span element is that it is an inline element, which means that you will not be able to set the width or height of it as is.
The CSS padding properties are used to generate space around an element's content, inside of any defined borders. With CSS, you have full control over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left).
margin is applied to block or inline-block elements
but not inline element like
span tags
try this
<span style='color:red;margin-right:1.25em; display:inline-block;'> </span>
Since span
elements are inline elements by default, horizontal margins are ignored for them by the spec. You can make them inline blocks (supported by most, but not all, browsers), or use padding instead of margin.
This probably won’t solve the ultimate problem, as the characters “*” and the no-break space are not of the same width, except by accident. To set up a table of data consisting of form fields and associated labels and explanations, use an HTML table, and then just add a little styling in CSS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With