为什么要使用HTML5语义标签,如headers,section,nav,和article而不是简单地div与首选css呢?
我创建了一个网页并使用了这些标签,但它们并没有什么区别div.他们的主要目的是什么?
是否仅在使用标签时使用适当的标签名称或更多?
请解释.我经历了很多网站,但我找不到这些基础知识.
我正在尝试创建一组图像对象,但很挣扎。每个对象将保存一个图像和图像的标题。
当我将其粘贴到 Firebug 中进行检查时,以下代码工作正常:
示例 1
var imageArray = new Array();
imageArray[0] = new Image();
console.log(imageArray[0]); //result is <img>
imageArray[0].src = "my-image-01.png";
console.log(imageArray[0]); // result is <img src="my-image-01.png"/>
imageArray[0] = {imageCaption: "A caption for the image"}; //an object
console.log(imageArray[0].imageCaption) //result is: A caption for the image
imageArray[1] = new Image()
Run Code Online (Sandbox Code Playgroud)
... 等等
但是,我认为以下内容更有意义,但它不断抛出错误,我不明白为什么。
示例 2
var imageArray = new Array();
imageArray[0]= {
image01: new Image(),
image01.src: "my-image-01.png", //"SyntaxError: missing : after property id"
imageCaption: "An image caption"
};
imageArray[1] = …Run Code Online (Sandbox Code Playgroud)