mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-07-13 21:15:35 +08:00
fix(curriculum): add guidance and tests for lowercase HTML tags (#61875)
This commit is contained in:
parent
428918f966
commit
ae6357fe43
@ -26,6 +26,12 @@ Your `h1` element should have an opening tag. Opening tags have this syntax: `<e
|
||||
assert.exists(document.querySelector('h1'));
|
||||
```
|
||||
|
||||
Your `h1` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?H1>/);
|
||||
```
|
||||
|
||||
Your `h1` element should have a closing tag. Closing tags have this syntax: `</elementName>`.
|
||||
|
||||
```js
|
||||
|
||||
@ -37,6 +37,12 @@ Your `h1` element's text should be 'CatPhotoApp'. You have either omitted the te
|
||||
assert.equal(document.querySelector('h1')?.innerText.toLowerCase(), 'catphotoapp');
|
||||
```
|
||||
|
||||
Your `h2` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?H2>/);
|
||||
```
|
||||
|
||||
Your `h2` element should have an opening tag. Opening tags have this syntax: `<elementName>`.
|
||||
|
||||
```js
|
||||
|
||||
@ -19,6 +19,12 @@ Your `p` element should have an opening tag. Opening tags have the following syn
|
||||
assert.exists(document.querySelector('p'));
|
||||
```
|
||||
|
||||
Your `p` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?P>/);
|
||||
```
|
||||
|
||||
Your `p` element should have a closing tag. Closing tags have a `/` just after the `<` character.
|
||||
|
||||
```js
|
||||
|
||||
@ -28,6 +28,12 @@ Your `h1` element should have an opening tag. Opening tags have this syntax: `<e
|
||||
assert(document.querySelector('h1'));
|
||||
```
|
||||
|
||||
Your `h1` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?H1>/);
|
||||
```
|
||||
|
||||
Your `h1` element should have a closing tag. Closing tags have a `/` just after the `<` character.
|
||||
|
||||
```js
|
||||
|
||||
@ -52,6 +52,12 @@ Your `h1` element's text should be `CatPhotoApp`. You have either omitted the te
|
||||
assert(document.querySelector('h1').innerText.toLowerCase() === 'catphotoapp');
|
||||
```
|
||||
|
||||
Your `h2` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?H2>/);
|
||||
```
|
||||
|
||||
Your `h2` element should have an opening tag. Opening tags have this syntax: `<elementName>`.
|
||||
|
||||
```js
|
||||
|
||||
@ -19,6 +19,12 @@ Your `p` element should have an opening tag. Opening tags have the following syn
|
||||
assert(document.querySelector('p'));
|
||||
```
|
||||
|
||||
Your `p` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?P>/);
|
||||
```
|
||||
|
||||
Your `p` element should have a closing tag. Closing tags have a `/` just after the `<` character.
|
||||
|
||||
```js
|
||||
|
||||
@ -28,6 +28,19 @@ Your `main` element should have an opening tag. Opening tags have this syntax: `
|
||||
assert(document.querySelector('main'));
|
||||
```
|
||||
|
||||
Your `main` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
const mainTagMatches = code.matchAll(/<\/?main>/gi);
|
||||
for (const match of mainTagMatches) {
|
||||
const tag = match[0];
|
||||
assert.strictEqual(
|
||||
tag,
|
||||
tag.toLowerCase()
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Your `main` element should have a closing tag. Closing tags have a `/` just after the `<` character.
|
||||
|
||||
```js
|
||||
|
||||
@ -13,7 +13,7 @@ HTML, which stands for Hypertext Markup Language, is a markup language for creat
|
||||
<p>Hello</p>
|
||||
```
|
||||
|
||||
Most elements will have an opening tag and a closing tag. Sometimes those tags are referred to as start and end tags. In between those two tags, you will have the content. This content can be text or other HTML elements. Both opening and closing tags start with a left angle bracket (`<`), and end with a right angle bracket (`>`), with the tag name placed between these angle brackets. Here is a closer look at just the opening and closing paragraph tags:
|
||||
Most elements will have an opening tag and a closing tag. Sometimes those tags are referred to as start and end tags. In between those two tags, you will have the content. This content can be text or other HTML elements. Both opening and closing tags start with a left angle bracket (`<`), and end with a right angle bracket (`>`), with the tag name placed between these angle brackets. While HTML tag names are case-insensitive, it is a widely accepted convention and best practice to write them in lowercase. Here is a closer look at just the opening and closing paragraph tags:
|
||||
|
||||
```html
|
||||
<p>
|
||||
|
||||
@ -26,6 +26,12 @@ Your `h1` element should have an opening tag. Opening tags have this syntax: `<e
|
||||
assert.exists(document.querySelector('h1'));
|
||||
```
|
||||
|
||||
Your `h1` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?H1>/);
|
||||
```
|
||||
|
||||
Your `h1` element should have a closing tag. Closing tags have this syntax: `</elementName>`.
|
||||
|
||||
```js
|
||||
|
||||
@ -37,6 +37,12 @@ Your `h1` element's text should be 'CatPhotoApp'. You have either omitted the te
|
||||
assert.equal(document.querySelector('h1')?.innerText?.trim().toLowerCase(), 'catphotoapp');
|
||||
```
|
||||
|
||||
Your `h2` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?H2>/);
|
||||
```
|
||||
|
||||
Your `h2` element should have an opening tag. Opening tags have this syntax: `<elementName>`.
|
||||
|
||||
```js
|
||||
|
||||
@ -19,6 +19,12 @@ Your `p` element should have an opening tag. Opening tags have the following syn
|
||||
assert.exists(document.querySelector('p'));
|
||||
```
|
||||
|
||||
Your `p` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /<\/?P>/);
|
||||
```
|
||||
|
||||
Your `p` element should have a closing tag. Closing tags have a `/` just after the `<` character.
|
||||
|
||||
```js
|
||||
|
||||
@ -28,6 +28,19 @@ Your `main` element should have an opening tag. Opening tags have this syntax: `
|
||||
assert.exists(document.querySelector('main'));
|
||||
```
|
||||
|
||||
Your `main` tags should be in lowercase. By convention, all HTML tags are written in lowercase.
|
||||
|
||||
```js
|
||||
const mainTagMatches = code.matchAll(/<\/?main>/gi);
|
||||
for (const match of mainTagMatches) {
|
||||
const tag = match[0]
|
||||
assert.strictEqual(
|
||||
tag,
|
||||
tag.toLowerCase()
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Your `main` element should have a closing tag. Closing tags have a `/` just after the `<` character.
|
||||
|
||||
```js
|
||||
|
||||
Loading…
Reference in New Issue
Block a user