1.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId
id | title | challengeType | videoUrl | forumTopicId |
---|---|---|---|---|
587d78aa367417b2b2512aec | 定义 HTML 文档的 head 和 body | 0 | https://scrimba.com/p/pVMPUv/cra9bfP | 301096 |
--description--
html
的结构主要分为两大部分:head
、body
。关于网页的描述都应该放入head
标签,网页的内容都应该放入body
标签。
比如link
、meta
、title
和style
都应该放入head
标签。
这是网页布局的一个例子:
<!DOCTYPE html>
<html>
<head>
<!-- metadata elements -->
</head>
<body>
<!-- page contents -->
</body>
</html>
--instructions--
给网页添加head
和body
,head
元素应该包含title
,body
元素应该包含h1
和p
。
--hints--
网页应该只有一个head
元素。
assert($('head').length == 1);
网页应该只有一个body
元素。
assert($('body').length == 1);
head
应该是html
的子元素。
assert($('html').children('head').length == 1);
body
应该是html
的子元素。
assert($('html').children('body').length == 1);
title
应该是head
的子元素。
assert(code.match(/<head>\s*?<title>\s*?.*?\s*?<\/title>\s*?<\/head>/gi));
h1
和p
都应该是body
的子元素。
assert(
code.match(
/<body>\s*?(((<h1>\s*?.*?\s*?<\/h1>\s*?)(<p>(.*\s*)*?<\/p>\s*?))|((<p>\s*?.*?\s*?<\/p>\s*?)(<h1>(.*\s*)*?<\/h1>\s*?)))<\/body>/gi
)
);