2
\$\begingroup\$
<!DOCTYPE html> <!--Declare the doctype as the html standard of HTML 5-->
<html lang="en-us"> <!--Lang Attribute to declare the language of a webpage-->
<head> <!--Every html doc needs a head which contains important information for viewing the code on different devices.-->
 <meta charset="UTF-8"> <!--The declaration of correct character encoding ensures proper interpretation and indexing for search purposes.-->
 <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!--Another default meta definition sets the user's device display area to a default.-->
 <title>Men need multiple mental health options. The content on this site holds no claim to expertise in the mental health profession.</title> <!--Primarily used for SEO, accurate titles help algorithms do their thang.-->
</head>
<body> <!--The body serves as the main content of your page.-->
<h1>Pitfalls</h1> <!--h1 represents a section of the body (a heading); the primary heading, followed by lower-priority additional headings in ascending order.-->
 <p>Nearly every man deals with major pitfalls in life <strong>--</strong> <em>depression, sorrow, rage, lonliness, jealousy, resentment </em></p> <!--A p tag represents a style, similar to a paragraph, and visually separates elements.-->
 <p>A pitfall is concealed.</p>
 <p>A pitfall takes work to maintain.</p>
 <p>A pitfall can ruin your life.</p>
 <p>You don't have to fall victim these traps. You can learn skills to overcome them, so that when you're faced with decisions that may lead to pitfalls, you can avoid them.</p>
 <p>The most important thing to remember is, the choice is yours.</p>
</body>
<footer><a href="/Users/******/Documents/bmi/page2.html">Learn more..</a></footer> <!--Sometimes important links or references are necessarily included in a footer, similar to a research document.-->
</html>

I want to make sure everything is proper with regards to HTML style and coding conventions, and comments. Indents are two (2) spaces. I took notes on each line to help me learn and remember.

200_success
146k22 gold badges190 silver badges479 bronze badges
asked Jul 20, 2021 at 3:43
\$\endgroup\$
1
  • \$\begingroup\$ A small remark about typographical conventions: Don't use two hyphens as a parenthetic dash. It should be either an en dash (with spaces around) or a em dash (without spaces). Either use the literal Unicode characters ( –, — ) or the HTML character references (&ndash;, &mdash;). Also using strong on it seems wrong. \$\endgroup\$ Commented Jul 20, 2021 at 9:17

1 Answer 1

3
\$\begingroup\$

HTML isn't intended for humans to read (but still it can be read), so that's more of a training, not real work. Real production HTML is better stripped of comments and spaces, minified and zipped to save network traffic. But if you need it to be readable...

Use validator

The only formal error here can be found immediately by an online validator: <footer> tag is out of <body>.

<strong> is not bold

The <strong> HTML element indicates that its contents have strong importance, seriousness, or urgency. It is shown in bold, but if you need bold font - use CSS, not <strong> tag.

Line width

If you need the code to be read by humans, limit string width. Traditional maximum width is somewhere near 80 symbols per line (80 or 78), but with modern wide screens you can make it some wider; check out how you see your code on this site. Break long lines.

Use same indentation for comments

If comments start at the same distance, it makes clear for reader they are of the same kind. Like

<!DOCTYPE html> <!--Declare the doctype as the html standard of HTML 5-->
<html lang="en-us"> <!--Lang Attribute to declare the language of a webpage-->
<head> <!--Every html doc needs a head which contains important 
 information for viewing the code on different devices.-->
 <meta charset="UTF-8"> <!--The declaration of correct character encoding ensures 
 proper interpretation and indexing for search purposes.-->
answered Jul 20, 2021 at 4:45
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.