freeCodeCamp/curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/introduction-to-html5-eleme...

3.1 KiB

id title challengeType videoUrl forumTopicId
bad87fee1348bd9aecf08801 Introduction to HTML5 Elements 0 https://scrimba.com/p/pVMPUv/cBkZGpt7 301097

Description

HTML5 introduces more descriptive HTML tags. These include main, header, footer, nav, video, article, section and others. These tags give a descriptive structure to your HTML, make your HTML easier to read, and help with Search Engine Optimization (SEO) and accessibility. The main HTML5 tag helps search engines and other developers find the main content of your page. Example usage, a main element with two child elements nested inside it:
<main> 
  <h1>Hello World</h1>
  <p>Hello Paragraph</p>
</main>

Note: Many of the new HTML5 tags and their benefits are covered in the Applied Accessibility section.

Instructions

Create a second p element after the existing p element with the following kitty ipsum text: Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. Then, create a main element and nest the two p elements inside the main element.

Tests

tests:
  - text: You should have 2 <code>p</code> elements with Kitty Ipsum text.
    testString: assert($("p").length > 1);
  - text: Each of your <code>p</code> elements should have a closing tag.
    testString: assert(code.match(/<\/p>/g) && code.match(/<\/p>/g).length === code.match(/<p/g).length);
  - text: Your <code>p</code> element should contain the first few words of the provided additional <code>kitty ipsum text</code>.
    testString: assert.isTrue((/Purr\s+jump\s+eat/gi).test($("p").text()));
  - text: Your code should have one <code>main</code> element.
    testString: assert($('main').length === 1);
  - text: The <code>main</code> element should have two paragraph elements as children.
    testString: assert($("main").children("p").length === 2);
  - text: The opening <code>main</code> tag should come before the first paragraph tag.
    testString: assert(code.match(/<main>\s*?<p>/g));
  - text: The closing <code>main</code> tag should come after the second closing paragraph tag.
    testString: assert(code.match(/<\/p>\s*?<\/main>/g));

Challenge Seed

<h2>CatPhotoApp</h2>

<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

Solution

<h2>CatPhotoApp</h2>
<main>
  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>