Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 91 additions & 8 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,105 @@
<title>My form exercise</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
button,
select {
min-height: 44px;
padding: 8px 12px;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow best practice, could you move the CSS code to an external file?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sure,CSS Code has been moved to a separate file as style.css


button {
margin-right: 8px;
}
</style>
</head>

<body>
<header>
<h1>Product Pick</h1>
</header>

<main>
<form>
<!-- write your html here-->
<!--
try writing out the requirements first as comments
this will also help you fill in your PR message later-->
<form action="results.html" method="GET">
Comment thread
cjyuan marked this conversation as resolved.
Outdated
<div>
<label for="name">Name</label>
<input
type="text"
name="Name"
id="name"
Comment on lines +22 to +25

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome's "Developer tools" identified this possible improvement:

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to include the autocomplete attribute. Thanks for the suggestion!

placeholder="Username"
pattern=".*\S.*\S.*"
title="Please enter at least two non-space characters."
required
/>
</div>

<div>
<label for="email">Email</label>
<input
type="email"
name="Email"
id="email"
placeholder="Email"
required
/>
</div>

T-shirt Color

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label does not have an accompanying semantic HTML element.

Could you use an AI tool to explore how you could improve the semantic structure of this form?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I’ve updated the form so the label is properly associated with its corresponding form control and improved the semantic structure where needed.


<div>
<label for="red">Red</label>
<input
type="radio"
name="color"
id="red"
value="Red"
required
/>
</div>

<div>
<label for="blue">Blue</label>
<input
type="radio"
name="color"
id="blue"
value="Blue"
/>
</div>

<div>
<label for="pink">Pink</label>
<input
type="radio"
name="color"
id="pink"
value="Pink"
/>
</div>

<div>
<label for="size">T-shirt Size</label>
<select name="T-shirt Size" id="size" required>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values of the name attributes are not very consistent. A common practice is to use either kebab-case or camelCase when naming them.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out I have used kebab-case and updated the name attributes to be consistent.

<option label="Select a size" value=""></option>
<option label="XS" value="XS"></option>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also consider the this syntax:

          <option value="XS">XS</option>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, corrected with the recommended syntax.

<option label="S" value="S"></option>
<option label="M" value="M"></option>
<option label="L" value="L"></option>
<option label="XL" value="XL"></option>
<option label="XXL" value="XXL"></option>
</select>
</div>

<div>
Comment on lines +89 to +95

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off.

Suggestion:

  • Look up the benefits of using a code formatter.
  • Install the Prettier extension for VS Code, then:
    • Use VS Code's Format Document feature to format your code.
    • Optionally, enable Format On Save and Format On Paste to keep your code consistently formatted.

Resource: Visual Studio Code - Formatting

Note: The formatter may not work correctly if your code contains syntax errors.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that! I have corrected the indentation.

<button type="reset">Reset</button>
<button type="submit">Submit</button>
</div>
</form>
</main>

<footer>
<!-- change to your name-->
<p>By HOMEWORK SOLUTION</p>
<p>By Perrila Tamang</p>
</footer>
</body>
</html>
</html>
Empty file added Form-Controls/results.html
Empty file.
Loading