开发者

problem in displaying span in HTML

I am creating nest开发者_JAVA百科ed spans as follows:

<span id="1">
   text1
   <span id="2"> text 2</span>
</span>

But somehow text 2 is being desplayed on new line , may be it is styles sheet issue but i cant chnage style sheet due to some other resons.How can i overide default style sheet and make text 2 to be displayed on same line as text1


<span style="display:inline;">


try <span id="2" style="display:inline;">


If they are not displaying one next to the other, then some of your CSS is setting its display: block (or similar) and not display: inline.

Easy fix - inspect the CSS setting it and remove, or explicitly state display: inline on that element.

Also, valid id (and name for that matter) attributes must start with a [a-zA-Z].


It is likely the stylesheet has set spans to display:block which causes them to take their own line, such as the default styling for a div. To fix this you can add a style attribute:

<span id="1">
   text1
   <span id="2" style="display:inline"> text 2</span>
</span>

However, this may still be overridden by the stylesheet if it is using the !important flag.

For future debugging I recommend you look at tools like Web Inspector (Safari and Chrome), Firebug (Firefox) and Dragonfly (Opera). One final note, you can't have an id attribute that begins with a number, it must start with a letter.


Try using the following: display:inline.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜