I have following html:
<table width="100%;>
<tr><hr style="width:100%;"></hr></tr>
<tr>
<span style="float:left">abc</span>
<span class="noindex" style="float:right">PageID</span>
</tr>
<br/>
<tr>Some text here...</tr>
</table>
I want to add 100px margin from right of the screen. i tried adding margin-right and removing width =100% it is not working.
The margin-right property in CSS is used to set the right margin of an element. It sets the margin-area on the right side of the element. Negative values are also allowed. The default value of margin-right property is zero.
You cannot see the effect of margin-right because the 'width' property of div causes the margin of div to have more than 10px distance from the right wall of the body. Consequently, it causes the margin-right property not to have any visual effect.
Another way of applying some margin on a <tbody> element is to use a ::before or ::after pseudo element. This way we basically add a new (empty) row which we can use to add some space at the beginning of our <tbody> elements.
margin-right will not work if you set width to 100%. What you could do is :
UPDATED If you are creating a page layout, then you should be using divs instead of tables. Tables are appropriate for data display (like custom grid style view).
<div>
<div style="margin-right:100px">
<table style="width:100%">
//your table
</table>
</div>
</div>
Hope it helps.
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