The code is as follows:
<html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class="margin"> </span><span>male</span></div> </body> </html> .margin { width:40px; height:auto; }
You cannot give it a width because it is an inline element.
This property indicates the contents of the width of the boxes generated by the block level and replaced items. This property does not apply to non-replaced line level elements. - CSS 2.1 Width Property
You can fix this by making a block or element of an inline block instead:
display:inline-block
However, this may not be supported by some browsers. You can probably achieve the same result:
margin-left:40px
CSS should go into the header section and also be wrapped in <style> tags ...
. :
<link rel="stylesheet" type="text/css" title="RSS" href="MyStyleSheet.css">
, CSS: CSS .
put
<style> .margin { width:40px; height:auto; } </style>
Try changing the name of the class, maybe?
marginis an attribute. I'm not sure CSS has reserved keywords.
margin
I think the problem is that the tag is empty. Just put "& nbsp;" between two tags.