← Community home

HTMLCodeRunner Editorial

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 100 total)
  • Author
    Posts
  • in reply to: Why does an HTML contact form not send mail by itself? #227

    Detailed answer

    HTML defines controls and a submission request.

    A server endpoint or service must process it, validate data, prevent abuse, and produce success or error feedback. Configure action and method deliberately. A mailto action depends on a local mail client and is not a reliable substitute for backend processing.

    Example

    <form action="/contact" method="post"><label for="message">Message</label><textarea id="message" name="message" required></textarea><button>Send</button></form>

    Understanding the behavior

    An HTML form collects and submits data to a destination; email delivery requires a server or trusted form service. The action URL must implement that process, including validation, abuse prevention and understandable success or failure responses.

    Practical implementation notes

    Test delivery to a real controlled inbox after deployment. A success screen alone does not prove that mail arrived, and mailto-based forms depend on the visitor's mail application rather than reliable server delivery.

    How to check it

    Inspect the real request and backend result, including error cases.

    Expected result

    Success feedback corresponds to actual processing rather than a timed animation.

    Watch out: A frontend success animation does not prove message delivery.

    Read the reference ↗

    in reply to: Why is my external stylesheet not applied? #229

    Detailed answer

    Check rel, resolved href, response status, and the stylesheet MIME type.

    Then confirm selectors match the DOM and inspect competing rules. A resource-path error and a cascade issue require different fixes. Verify the actual response rather than changing random selectors when the server may be returning HTML.

    Example

    <link rel="stylesheet" href="/styles/site.css">

    Understanding the behavior

    A stylesheet link must resolve to an accessible CSS resource with an appropriate response type. A successful download still may not affect the page if selectors do not match, a media condition excludes it or another rule wins the cascade.

    Practical implementation notes

    Inspect the network request first, then the element's matched and computed styles. Disable caching during investigation when necessary, but do not assume cache is the cause before checking the resolved path and response.

    How to check it

    Open the response body and Content-Type, then inspect selector matching only after the file is valid.

    Expected result

    The stylesheet response contains CSS rather than a fallback HTML page.

    Watch out: A 200 response containing an HTML error page is not a stylesheet.

    Read the reference ↗

    in reply to: How do you debug an external script that does not run? #231

    Detailed answer

    Inspect the request and console first.

    Confirm src resolves to JavaScript rather than an HTML fallback page, and look for loading restrictions or syntax errors. Defer helps a classic script that needs parsed content. Fix the earliest failure before treating every missing behavior as a separate bug.

    Example

    <script src="/scripts/preview.js" defer></script>

    Understanding the behavior

    Separate loading failures from execution failures. A script may load successfully and then stop at an earlier exception, query an element before it exists or be blocked by a policy. Module imports introduce additional URL and MIME requirements.

    Practical implementation notes

    Start with the first console error and inspect the corresponding request. Add a small observable test near the entry point, then follow execution toward the failing interaction rather than changing several unrelated settings at once.

    How to check it

    Inspect the script response before debugging its functions or event handlers.

    Expected result

    The script URL returns JavaScript, not a catch-all HTML route.

    Watch out: A catch-all router may return HTML for a missing script URL.

    Read the reference ↗

    in reply to: What should you check before sharing an HTML project? #233

    Detailed answer

    Check document structure, descriptive headings, working links, labeled fields, alternative text, and narrow-screen behavior.

    Navigate using only the keyboard and verify resources from the deployed location. Share a minimal example when asking for help and remove private information. One successful visual check in one browser is only a starting point.

    Example

    <main><h1>My HTML project</h1><p>What this page does.</p><a href="/examples/">Explore examples</a></main>

    Understanding the behavior

    A release check should cover meaningful behavior, not just whether the homepage looks attractive. Test navigation, forms, missing pages, keyboard access, mobile layout, resource paths and metadata using the deployed URL. Local success does not prove production mail or HTTPS configuration.

    Practical implementation notes

    Keep a backup and a short deployment checklist, then verify the live version after upload. Record any remaining limitations honestly and avoid publishing test credentials, private configuration or placeholder legal and contact details.

    How to check it

    Test keyboard navigation, narrow layouts, resource paths, and meaningful structure before sharing a minimal example.

    Expected result

    A reviewer receives a reproducible HTML problem without private source data.

    Watch out: Check both the rendered experience and the actual document structure.

    Read the reference ↗

    in reply to: What does contenteditable provide and what is still missing? #209

    Detailed answer

    It lets people edit a region, but does not create a full editor or a standard form field.

    Saving, naming, keyboard behavior, and pasted content still need handling. Treat edited content as untrusted when storing or sharing it. Prefer native fields when a simple text input is sufficient.

    Example

    <div contenteditable="true" role="textbox" aria-label="Editable lesson note">Write an HTML note.</div>

    Understanding the behavior

    Contenteditable makes a region editable but does not provide a complete editor, form submission, storage or sanitization system. Pasted content can include formatting and unexpected markup. A conventional textarea may be more appropriate for plain text input.

    Practical implementation notes

    Test keyboard navigation, paste, undo and saving. Treat edited HTML as untrusted when it is stored or displayed elsewhere, and provide an accessible name and clear instructions for the editing region.

    How to check it

    Define the save flow explicitly and test pasted markup before storing anything.

    Expected result

    Editing, persistence, and sanitization are treated as separate responsibilities.

    Watch out: Do not publish raw edited HTML without appropriate sanitization.

    Read the reference ↗

    in reply to: How are progress and meter different? #211

    Detailed answer

    Progress describes completion of a task; meter describes a scalar measurement within a known range.

    Give either one a useful label and accurate values. Progress without value represents indeterminate progress. Do not show invented completion merely to suggest activity, and avoid meter for a task that is still running.

    Example

    <label for="upload">Upload progress</label><progress id="upload" value="30" max="100">30%</progress>
    <label for="score">Quiz score</label><meter id="score" min="0" max="10" value="8">8 of 10</meter>

    Understanding the behavior

    Progress describes completion of a task, while meter describes a scalar measurement within a known range. Their value and limit attributes need to reflect the real quantity. A decorative percentage without context is difficult to interpret.

    Practical implementation notes

    For progress without a known total, omit value to express an indeterminate task. For a measurement, label the units and range so a value such as 70 is not mistaken for 70 percent completed.

    How to check it

    Check the intended meaning, label, range, and current value for each element.

    Expected result

    Progress describes a running task; meter describes a bounded measurement.

    Watch out: Task completion and a measurement within a range are different concepts.

    Read the reference ↗

    in reply to: When are datalist suggestions useful? #213

    Detailed answer

    Datalist offers suggestions to a compatible input without forcing selection from them.

    Match the input list attribute to the datalist id. Use select when the person must choose a fixed option. Browser and assistive-technology behavior varies, so test the combinations your users need rather than assuming identical presentation.

    Example

    <label for="topic">HTML topic</label><input id="topic" name="topic" list="topics"><datalist id="topics"><option value="Forms"><option value="Tables"></datalist>

    Understanding the behavior

    Datalist provides suggestions to a compatible input while still allowing other values. It differs from a select, which presents a constrained option set. Browser and assistive-technology experiences vary, so test the actual audience's supported combinations.

    Practical implementation notes

    If the server only accepts certain values, validate that requirement separately. Do not assume that selecting from suggestions is mandatory or that every browser presents the same dropdown interface.

    How to check it

    Associate list with the datalist id and enter a value not among the suggestions.

    Expected result

    The input can accept free text; a fixed-choice rule needs separate validation.

    Watch out: Suggestions are not server-side validation of allowed values.

    Read the reference ↗

    in reply to: How do you start debugging invalid HTML? #215

    Detailed answer

    Reduce the problem to a small example and run it through an HTML checker.

    Fix structural errors from the top, because one malformed tag can cause several later messages. Compare source with the parsed DOM and retest after changes. Validation checks syntax; it does not prove accessibility or complete application correctness.

    Example

    <!doctype html><html lang="en"><head><title>Validation example</title></head><body><p>A complete paragraph.</p></body></html>

    Understanding the behavior

    Start with the smallest failing document and fix structural errors before chasing visual symptoms. Browser recovery can make invalid source appear partly functional, so compare source, parsed DOM and validator messages. The first structural error can cause several later warnings.

    Practical implementation notes

    Reproduce the issue after each meaningful fix. A validator checks markup conformance, but it does not establish correct business logic, accessible interaction or a useful visual layout by itself.

    How to check it

    Fix the first structural problem and rerun the checker before editing every later warning.

    Expected result

    Cascading messages can disappear when the underlying markup is corrected.

    Watch out: Several validator messages can have one root cause.

    Read the reference ↗

    in reply to: Why does the browser move elements out of a paragraph? #217

    Detailed answer

    Paragraphs cannot contain arbitrary flow elements such as div.

    The parser may close a paragraph before the disallowed element, leaving a DOM different from the source indentation. Use a container around separate paragraphs and blocks. The Elements panel shows what the browser actually constructed and is useful for finding this mismatch.

    Example

    <div><p>An introduction.</p><div class="example">Example markup</div><p>A conclusion.</p></div>

    Understanding the behavior

    A paragraph cannot contain every type of block content. When an incompatible element begins, the HTML parser may close the paragraph automatically and create a DOM that differs from the indentation in source. This behavior is parsing, not a CSS margin problem.

    Practical implementation notes

    Move the larger structure outside the paragraph and inspect the new DOM. Use paragraphs for text runs and separate containers for lists, sections or other structures rather than forcing them into a p wrapper.

    How to check it

    Place the block outside p, reload, and compare the Elements tree with the valid structure.

    Expected result

    The parser no longer has to close a paragraph around invalid nested flow content.

    Watch out: Indentation does not override HTML content-model rules.

    Read the reference ↗

    in reply to: How can repeated components introduce duplicate IDs? #219

    Detailed answer

    A repeated template can accidentally give every instance the same id.

    Fragment navigation, labels, and scripts may then resolve to the wrong element. Use classes for repeated grouping and generate unique IDs for individual controls. Check the rendered document, not just one source file or template definition.

    Example

    <label for="email-main">Main email</label><input id="email-main" name="email_main">
    <label for="email-backup">Backup email</label><input id="email-backup" name="email_backup">

    Understanding the behavior

    A component's internal IDs can become duplicated when the same markup is rendered repeatedly. Labels, description references and fragment links may then refer to an unintended instance. Uniqueness must be maintained across the complete document, not just one component file.

    Practical implementation notes

    Generate a stable unique prefix for each instance and update matching for, aria-describedby and href references. Test both the first and later copies, since the first copy can appear correct while others fail.

    How to check it

    Generate different control IDs for each instance while retaining the shared styling class.

    Expected result

    Each label targets its own input rather than an ambiguous duplicate.

    Watch out: A template can look valid alone but become invalid when repeated.

    Read the reference ↗

    in reply to: Why is an image broken even though its file exists? #221

    Detailed answer

    Check the resolved URL, response status, filename case, and document directory.

    A case mismatch can work locally but fail on a different hosting filesystem. The network panel shows the actual request rather than the intended disk path. Keep useful alternative text while fixing the unavailable resource.

    Example

    <img src="/images/html-example.png" alt="An HTML example page" width="640" height="360">

    Understanding the behavior

    An image path is resolved as a URL, not as the file manager's current folder. Deployment can expose case mismatches that a local system tolerated. The response can also fail because of permissions, a wrong base URL or an HTML fallback response.

    Practical implementation notes

    Open the resolved image URL and inspect its status and content type. A successful 200 response containing an error page is still not a valid image, so check the returned body as well as the code.

    How to check it

    Compare case, separators, resolved URL, and actual response on the target host.

    Expected result

    The browser requests the correctly cased URL rather than a filesystem path.

    Watch out: Windows backslashes are not portable web URL separators.

    Read the reference ↗

    in reply to: How do you debug garbled characters in HTML? #223

    Detailed answer

    Check file encoding, charset metadata, response headers, and any database or template transformations.

    These stages must agree on how bytes represent text. Test a minimal UTF-8 document with representative characters to isolate the failure. Keep an undamaged original before attempting conversions rather than repeatedly re-encoding already corrupted text.

    Example

    <!doctype html><meta charset="utf-8"><title>Encoding check</title><p>नमस्ते — café — HTML</p>

    Understanding the behavior

    Encoding problems can begin when a file is saved, when a server declares its charset or when data is decoded before reaching the page. A replacement character or mojibake can already be stored in the content. Changing one meta tag cannot recover lost original bytes.

    Practical implementation notes

    Trace a short non-ASCII sample from its source through storage to the response. Keep the actual file encoding, database connection and HTTP declaration consistent, then correct any previously damaged text.

    How to check it

    Trace the original bytes through storage and HTTP response, keeping a clean source copy.

    Expected result

    The damaged stage is identified instead of applying repeated blind conversions.

    Watch out: Character references can conceal a symptom without repairing the encoding pipeline.

    Read the reference ↗

    in reply to: How do you show HTML code without executing it? #225

    Detailed answer

    Escape the example and place it in pre and code when formatting matters.

    When inserting text with JavaScript, textContent treats it as text rather than markup. The page around the example still needs valid structure. Do not execute user code merely to show the code's source in a discussion.

    Example

    <pre><code><h1>Hello HTML</h1></code></pre>

    Understanding the behavior

    Pre preserves formatting and code marks a code fragment, but neither turns markup into literal text automatically. Escape the source before placing it in the document. Applying escaping repeatedly can also make entities display visibly rather than as the intended characters.

    Practical implementation notes

    Check the parsed DOM for unexpected elements from the sample. In JavaScript-driven examples, assign textContent so the snippet remains text even when it includes tag-like characters or quotes.

    How to check it

    Render escaped source in code or assign a string through textContent.

    Expected result

    The tag appears literally without becoming an active document element.

    Watch out: An unescaped closing tag can change the surrounding document.

    Read the reference ↗

    in reply to: Why does template content not appear immediately? #205

    Detailed answer

    Template holds inert markup for later instantiation.

    JavaScript can clone its content and insert the result into the document. This separates a reusable structure from its instances. Keep cloned IDs unique and use safe text insertion for user values. A template is not an automatic loop or rendering framework.

    Example

    <template id="card"><article><h2>HTML example</h2></article></template>
    <script>document.body.append(document.querySelector("#card").content.cloneNode(true));</script>

    Understanding the behavior

    Template stores a fragment that is not rendered as normal document content until code clones or inserts it. Its content is available through the template's content DocumentFragment. Repeated clones still need distinct IDs when they contain labeled controls or fragment targets.

    Practical implementation notes

    Clone the fragment, append it to a visible container and inspect the resulting elements. If the template contains dynamic user text, insert that text safely instead of constructing unsanitized HTML strings.

    How to check it

    Clone template.content and append the clone, then check repeated instances for duplicate IDs.

    Expected result

    Only inserted clones become ordinary rendered content.

    Watch out: Repeated cloning can introduce duplicate IDs.

    Read the reference ↗

    in reply to: How do data attributes connect markup and JavaScript? #207

    Detailed answer

    Data attributes attach application-specific information to an element and are available through dataset.

    Values are strings, so parse them deliberately when code expects another type. Keep them separate from native semantic attributes. Anything placed in HTML is visible to the visitor; these attributes are not secret storage.

    Example

    <button type="button" data-example-id="forms-01">Open example</button>

    Understanding the behavior

    Data attributes store application-specific strings on elements. Dataset maps attribute names to JavaScript property names, but values remain strings until explicitly parsed. These attributes are visible to visitors and are unsuitable for storing secrets.

    Practical implementation notes

    Check how data-item-id becomes dataset.itemId, then validate values before using them. A value of false is still a non-empty string, so a simple truthiness test may not express the intended boolean state.

    How to check it

    Read button.dataset.exampleId and inspect its type before using it.

    Expected result

    The value is a string; numeric and boolean meanings need deliberate conversion.

    Watch out: A dataset value of false is still a nonempty string unless parsed.

    Read the reference ↗

Viewing 15 posts - 1 through 15 (of 100 total)