Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net W3C验证程序错误_Asp.net_Html_Image_Xhtml_W3c Validation - Fatal编程技术网

Asp.net W3C验证程序错误

Asp.net W3C验证程序错误,asp.net,html,image,xhtml,w3c-validation,Asp.net,Html,Image,Xhtml,W3c Validation,当我使用W3CValidator检查我的站点时,它会显示 “所需属性”alt“未指定”以及 “上面给出的属性对于您使用过的元素是必需的,但您忽略了它。例如,在大多数HTML和XHTML文档类型中,“script”元素需要“type”属性,而“img”元素需要“alt”属性。type的典型值是type=“text/css”for and type=”text/javascript“for.” 我如何解决这个问题 截图: 这是我的代码: protected string GetImageStyle

当我使用W3CValidator检查我的站点时,它会显示

“所需属性”alt“未指定”以及

“上面给出的属性对于您使用过的元素是必需的,但您忽略了它。例如,在大多数HTML和XHTML文档类型中,“script”元素需要“type”属性,而“img”元素需要“alt”属性。type的典型值是type=“text/css”for and type=”text/javascript“for.”

我如何解决这个问题

截图:

这是我的代码:

protected string GetImageStyle(ImageStub image)
    {
        if (!image.ImageID.IsNull)
        {
            image = image.ScaleOptimalWidth(75, 75);
            return String.Format("width:75px;height:75px;align='left';-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px; padding-left: 2px;alt='img';");
        }

        return "width:75px;height:75px;align='left';alt='img'";
    }

alt
属性添加到您的
标记中。

有关更详细的说明,请参阅@Sujanth,根据您在样式属性中放置alt的屏幕截图,它应该是单独的attribute@Sujanth你应该在
的时候有这个“img”
肯定不是有用的替代内容。也许验证器现在足够聪明,能够识别这一点。如果你只是为了得到一个验证器徽章而添加无意义的替代文本,不要麻烦了。但我怀疑问题在于,您管道中的某些内容是对引号进行HTML编码的,因此验证程序无法识别虚假的替代文本。让我们来看看您的代码当前是什么。