xhtml代码"浮动:正确"并且"明确:正确"无效

时间:2017-11-14 04:00:02

标签: xhtml css-float

图像文件向右浮动确定。这是一个跨度风格的段落,带有" clear:right"未清除图像的属性。文本出现在右边的边距没有元素之前,在这种情况下是图像。

这是body标签之间的所有代码。该文件具有xml prolog,具有使用xhtml transitional的DTD,开始标记包含指定HTML命名空间的xmlns属性。

<h1 style="text-align: center">Tourist Attractions</h1>

<hr />

<p>
<img src="images/child.jpg" alt="child" style="border: 5px ridge orange; 
float: right" />
<span style="font-weight: bold; font-family: arial, helvetica, sans serif; 
color: darkblue">

The City of Desert Park has many opportunities for fun, recreation, and 
entertainment. Throughout every month, you will find activities for all ages 
and lifestyles. The weather in Desert Park is conducive to outdoor 
activities year-round.

</span>
</p>
<p><span style="font-family: arial, helvetica, sans-serif; color: darkblue; 
clear: right">

Visit the Parks and Recreation Page for the latest information on the 
Basketball League Play-off Games.

</span>
</p>

第二段没有清除右边的图像。我知道&#34;清楚&#34;属性仅清除前一个元素。但是图像在&#34; clear&#34;之前。标签。我无法弄清楚它为什么不清除。我上次使用xhtml已经有几年了。我知道html5是东西,但DTD指向xhtml过渡,所以它应该仍然有效。

有人可以告诉我为什么第二段没有清除右边的图像?我可能一直在考虑这个问题,答案就在我面前。感谢您的回复。

1 个答案:

答案 0 :(得分:0)

clear属性仅适用于块级元素。默认情况下,Span元素是内联级别,您不会更改它。将clear:right移动到包含p元素的范围,清除将生效。

这不是特定于XHTML 1.0 Transitional。 HTML5将完全相同。