Category: HTML

  • How to Open an HTML Link in a New Tab

    How to Open an HTML Link in a New Tab

    To open an HTML link in a new tab, add the target=”_blank” attribute to a normal anchor. Keep the destination in href, then place the visible link text between the opening and closing a tags. This pattern requests a new browsing context without JavaScript and works for ordinary text navigation.

    The browser or the user’s settings ultimately determine whether that new context appears as a tab or a window. Therefore, target=”_blank” requests the behavior; it does not guarantee a particular piece of browser interface.

    How to Open an HTML Link in a New Tab: The Complete Anchor Example

    Use this complete anchor when the link should request a separate browsing context:

    <a href=”https://example.com/resources” target=”_blank” rel=”noopener”>Open the resource</a>

    The href attribute contains the destination URL. The target attribute controls where the browser requests that destination, and _blank names a new, unnamed browsing context. The words “Open the resource” become the clickable link text.

    rel=”noopener” is a useful companion for links that open another document. It prevents the newly opened page from using the opener reference to interact with the original page. It does not create the new tab; target=”_blank” makes that request.

    How Does target=”_blank” Change Navigation?

    Without a target attribute, a link normally loads its href in the current browsing context. With target=”_blank”, the browser asks for a new top-level context instead. In common desktop configurations, that context appears as a new tab, while some configurations open a new window.

    • The original page remains available in its existing tab or window.
    • The destination loads in the newly requested context.
    • The browser may apply popup-blocking, tab preferences, or other user controls.

    The keyword _blank does not force a physical tab. A browser or user setting ultimately decides whether the result is a tab or a window. Keyboard commands and accessibility preferences can also affect how a link opens. The HTML declares the requested browsing context, not the final interface choice.

    How Do You Use an HTML href to Open a Link in a New Tab?

    An href for a new tab is still an ordinary URL paired with target=”_blank”. Apply the same pattern to text links, product names, documentation references, or any other element that users expect to activate as a link:

    <a href=”/documentation” target=”_blank” rel=”noopener”>Read the documentation</a>

    For an image link, place the image element inside the anchor and keep the same attributes on the anchor:

    <a href=”/gallery” target=”_blank” rel=”noopener”><img src=”/images/gallery-preview.jpg” alt=”View the image gallery”></a>

    The image becomes clickable because it is nested inside the a element. Provide meaningful alt text so users who cannot see the image still understand the link’s purpose. The anchor’s href remains the destination, while its target requests the separate context.

    When Is Same-Tab Navigation Clearer?

    Same-tab navigation is often clearer when the destination is part of the same task or site journey. It preserves the browser’s normal back-button flow and avoids accumulating extra tabs. Omit the target attribute for the default behavior, or state it explicitly:

    <a href=”/account” target=”_self”>Open your account</a>

    • Use same-tab navigation for related pages, form steps, account areas, and primary site content.
    • Request a new context for supporting resources that users may need to consult while keeping the current page open.
    • Describe the destination clearly so users can choose how they want to open it.

    Use target=”_blank” deliberately rather than on every link. The clearer choice depends on whether preserving the current page helps the user complete the task.

  • HTML dialog: Modal and Non-Modal Examples

    HTML dialog: Modal and Non-Modal Examples

    Use the native HTML dialog element to build a modal or non-modal interface without recreating its focus and keyboard behavior with a generic div. The example below is a complete HTML dialog with two triggers, a method=dialog form, and JavaScript for opening and closing it.

    When a dialog is shown, the element receives the open state. The opening method determines whether the rest of the page remains interactive.

    Create an HTML dialog box with a form close action

    Place the trigger buttons and dialog in the document. A form with method=”dialog” closes its nearest dialog when a submit button is activated. The clicked button’s value becomes the dialog’s return value.

    Markup: <button type=”button” id=”open-modal”>Open modal</button> <button type=”button” id=”open-nonmodal”>Open non-modal</button> <dialog id=”account-dialog”> <form method=”dialog”> <h2>Account settings</h2> <p>Choose an action for this account.</p> <button value=”cancel”>Cancel</button> <button value=”save”>Save</button> </form> </dialog>

    The two buttons use type=”button” so they do not submit a surrounding form. The dialog’s Cancel and Save buttons are submit controls for the dialog form, so either one closes the dialog without requiring a custom click handler.

    Open an HTML5 dialog with show() or showModal()

    Call show() for non-modal behavior. The dialog opens, but users can still interact with the rest of the page. Call showModal() for modal behavior. The browser renders a backdrop, keeps interaction inside the dialog, and manages modal focus.

    JavaScript: const dialog = document.querySelector(“#account-dialog”); const modalButton = document.querySelector(“#open-modal”); const nonModalButton = document.querySelector(“#open-nonmodal”); modalButton.addEventListener(“click”, () => { dialog.showModal(); }); nonModalButton.addEventListener(“click”, () => { dialog.show(); });

    • show() opens the dialog without making the document modal.
    • showModal() opens it as a modal dialog and enables ::backdrop styling.
    • Both methods set dialog.open to true. Do not call either method again while the same dialog is already open.

    Close the dialog, handle events, and read a return value

    Pressing Escape on a modal dialog normally fires the cancel event and then closes the dialog. Listen for cancel when you need to prevent that default behavior, such as when unsaved changes require confirmation. The close event fires after any closing method, including a dialog-form submission.

    Use close(value) to close the element from JavaScript. Its optional value is exposed through dialog.returnValue. The form buttons above return cancel or save.

    Closing and events: dialog.addEventListener(“cancel”, (event) => { /* event.preventDefault() keeps it open */ }); dialog.addEventListener(“close”, () => { console.log(dialog.returnValue); }); dialog.close(“programmatic”);

    After close(), the open property becomes false. The close event is the suitable place to update the page based on the selected value, while the cancel event is the suitable place to intercept Escape before the default close occurs.

    Style the HTML dialog and its ::backdrop

    Target the dialog directly for its panel appearance. The ::backdrop pseudo-element applies to the viewport layer created by showModal(); a non-modal dialog does not receive that modal backdrop.

    CSS: dialog { border: 0; border-radius: 0.5rem; padding: 1.5rem; max-width: 32rem; } dialog::backdrop { background: rgb(0 0 0 / 55%); }

    Keep the close controls inside the dialog form when their purpose is to return a user-selected result. Use close(value) for programmatic outcomes that are not represented by a form button.

  • HTML fieldset: Group Related Form Controls with legend and CSS

    HTML fieldset: Group Related Form Controls with legend and CSS

    An HTML fieldset groups form controls that belong to one topic, while a legend names that group. This gives screen-reader users a clear question or category before they encounter the controls. Build the semantic structure first, then use CSS to add the visual boundary, spacing, and layout.

    The HTML fieldset tag is especially useful for radio buttons because the shared name makes the inputs one-choice controls, while the legend identifies what that choice answers.

    How does an HTML fieldset group related controls?

    Place related controls inside fieldset and put the group label in its first child, legend. Unlike a heading styled to look similar, legend is programmatically associated with the fieldset. Each control still needs its own label. Connect a label’s for value to the input’s unique id, so clicking the text also selects or focuses the control.

    Use one name for mutually exclusive radio buttons, and give every option a distinct value. Do not use placeholder text as a substitute for a label: placeholders disappear and do not identify a completed choice reliably.

    How does the HTML fieldset tag work in a radio-button form?

    This complete radio-button form includes the group label, three individually labelled options, and a submit control:

    Complete markup: <form action=”/preferences” method=”post”> <fieldset> <legend>Contact preference</legend> <input type=”radio” id=”email” name=”contact” value=”email” required> <label for=”email”>Email</label> <input type=”radio” id=”phone” name=”contact” value=”phone”> <label for=”phone”>Phone</label> <input type=”radio” id=”none” name=”contact” value=”none”> <label for=”none”>No contact</label> </fieldset> <button type=”submit”>Save preference</button> </form>

    The legend, “Contact preference,” labels the entire group. Each label identifies one answer, and the matching for and id attributes preserve that relationship even if the visual layout changes. The shared contact name lets the browser enforce a single radio selection. The required attribute on one radio makes choosing an option mandatory for the group.

    How do you disable an entire fieldset?

    Add the disabled attribute to the fieldset opening tag when the whole group is unavailable:

    Disabled group: <fieldset disabled> <legend>Contact preference (unavailable)</legend> … </fieldset>

    Disabled fieldset controls cannot receive focus or user input, and their values are not submitted with the form. The legend remains readable, which allows the group’s status to be communicated. Keep important explanatory text in the legend or nearby content rather than placing interactive controls inside the legend.

    How do you style a CSS fieldset?

    Use a CSS fieldset rule for the border, padding, and internal layout. Style legend separately because browsers apply their own default border placement and spacing:

    CSS: fieldset { border: 2px solid #b8c0cc; padding: 1rem; display: grid; gap: .5rem; max-inline-size: 24rem; } legend { padding-inline: .5rem; font-weight: 700; } fieldset label { display: flex; align-items: center; gap: .5rem; }

    The border creates the visual group, while padding keeps controls away from its edge. The grid display and gap property provide consistent vertical spacing without adding presentational markup. The label rule aligns each radio button with its text and enlarges the useful click area. Adjust the border color, thickness, and maximum width to match the surrounding form while keeping sufficient contrast.

  • HTML main: How to Mark Up Primary Page Content

    HTML main: How to Mark Up Primary Page Content

    The HTML main element identifies the dominant content unique to the current document. Put the page’s article, product details, search results, dashboard view, or other primary task inside <main>; keep repeated site chrome outside it. The element also exposes a main landmark to assistive technology.

    Use one non-hidden main landmark at a time. A page can contain several main elements in its source when inactive views are hidden, but users should normally encounter only one exposed main landmark.

    What belongs in the HTML main element?

    Content belongs in the HTML main element when it distinguishes this document or view from other pages on the site. It should answer the page’s primary purpose rather than describe the surrounding website.

    • An article page’s heading, publication details, body, and related in-article sections.
    • A product page’s product information, pricing, specifications, and purchase controls.
    • A search page’s search heading, filters that control the results, and result list.
    • A dashboard’s active report, task area, or application view.

    The main element may contain headings, paragraphs, lists, forms, articles, sections, and other elements needed to present that content. A page-specific sidebar can belong inside <main> when it directly supports the document, while a repeated site-wide sidebar generally belongs outside it.

    A complete page structure: where main content fits

    Place <main> inside <body>, alongside the page’s repeated structural landmarks. A compact structure looks like this:

    <body> <header>Site identity</header> <nav>Primary links</nav> <main>Unique page content</main> <aside>Related site content</aside> <footer>Site information</footer> </body>

    • Header: identifies the site or page and may contain branding or introductory material.
    • Navigation: provides links for moving through the site or application.
    • Main: contains the document’s dominant, page-specific content.
    • Aside: contains tangential or supporting content, such as related links.
    • Footer: contains closing information, legal links, or repeated contact details.

    For an article, the article heading and text usually sit inside <main>. An article-specific header can sit inside the article, while the site header remains a sibling of main.

    How HTML main differs from header, nav, aside, and footer

    These elements describe different structural responsibilities. Location alone does not determine whether content belongs in main.

    • <header> introduces a site, page, article, or section. A site-wide header is repeated boilerplate, not the page’s main content.
    • <nav> groups navigation links. Primary menus, account menus, and breadcrumb navigation should not be placed in main merely because they appear above the content.
    • <aside> holds content related to, but separate from, the primary flow. A recurring “Most popular” panel or advertising block usually belongs outside main.
    • <footer> provides closing information for the site, page, article, or section. A repeated site footer does not become main content.

    Use <section> inside main for a thematic group that needs its own heading. Use <article> for a self-contained item, such as a post or product review. The main element is the broader landmark that contains the page’s primary experience.

    Can hidden views expose more than one HTML main element at once?

    Normally, expose only one non-hidden HTML main element at a time. Assistive technology uses the main landmark as a shortcut to the primary content, so multiple simultaneously exposed main landmarks can create ambiguity.

    Application shells and single-page interfaces may keep several views in the document. In that case, keep the active view in one main element and hide inactive views with the HTML hidden state or an equivalent accessibility-safe mechanism. For example, an inactive view can be represented as <main hidden>, while the active view remains exposed.

    • Do not leave several alternate screens visible and mark each one as main.
    • Do not rely only on visual positioning to hide an inactive landmark from assistive technology.
    • When switching views, remove the hidden state from the new main view before exposing it and hide the previous one.

    If the application uses one persistent main landmark and swaps its contents, that also satisfies the one-visible-main pattern.

  • Footer HTML: Complete Examples for Pages and Articles

    Footer HTML: Complete Examples for Pages and Articles

    Footer HTML marks supporting information for the nearest page or section. Use one document-level footer for site-wide details, or place a footer inside an article when the information belongs specifically to that article.

    The element provides meaning, not a fixed visual position. CSS determines whether the footer stays in normal flow, appears at the bottom of a layout, or changes position at a particular viewport width.

    What does footer HTML represent, and does it set a visual position?

    The footer element represents closing or supporting content for its nearest sectioning context. At page scope, it describes information about the whole document. Inside an article, it describes information about that article. Inside another sectioning element, such as section, it belongs to that section.

    A footer tag HTML example is interpreted by this surrounding structure; the element does not automatically mean “the bottom of the screen.” It can contain copyright information, related links, author details, publication dates, contact information, or other content associated with its scope.

    A document footer does not have to be the final child of the body. Place it where the document structure and reading order make sense, then use CSS for spacing, alignment, columns, backgrounds, or fixed positioning.

    How should a document-level footer be marked up with site information and navigation?

    Use a document-level footer for information that supports the entire site or page. Site identification, a navigation list, legal links, and general contact details are appropriate examples. The following footer HTML code shows those items together:

    <footer> <p>&copy; 2025 Example Journal</p> <nav aria-label=”Footer navigation”> <ul> <li><a href=”/about”>About</a></li> <li><a href=”/privacy”>Privacy</a></li> <li><a href=”/contact”>Contact</a></li> </ul> </nav> <address>Email: <a href=”mailto:[email protected]”>[email protected]</a></address> </footer>

    The nav element identifies the group as navigation, while the list organizes its links. The address element is suitable for contact information related to the site or its owner. A footer can contain several navigation groups, but each group should have a clear purpose and accessible label.

    For a page-specific shell, the same structure can sit after the main content inside a wrapper. Its scope remains document-level if it is not nested inside an article or another sectioning context.

    When should you use the HTML footer tag inside an article for author metadata?

    Use an article footer when the information describes the article rather than the whole site. Common content includes the author, publication date, update date, categories, tags, licensing information, or links to related article resources.

    This example shows an article footer with author metadata:

    <article> <h2>Choosing Accessible Color Contrast</h2> <p>Readable contrast supports visitors across devices and lighting conditions.</p> <footer> <p>Written by Maya Chen</p> <p>Published on January 12, 2025; updated on February 3, 2025</p> </footer> </article>

    Here, the inner footer belongs to the article because it is nested within the article element. A separate site footer can still appear outside the article and provide global navigation or contact details. Do not use an article footer merely to force content below the article with CSS.

    What belongs in footer HTML code, including contact details?

    Choose footer content according to scope:

    • Document scope: site name, copyright notice, global navigation, privacy links, accessibility information, and general contact details.
    • Article scope: author name, publication or update dates, categories, tags, licensing details, and article-specific related links.
    • Section scope: supporting information that applies only to that section, such as a section editor or a link to its complete archive.

    Keep the structure meaningful. Use paragraphs for short notices, lists for groups of links, and navigation markup for a distinct navigation region. Contact details can appear in an address element when they identify the relevant site, organization, or author. A footer supplies semantics and reading structure; it does not create columns, a sticky bar, a bottom alignment, or any other visual treatment without CSS.

  • Textarea: Markup, Initial Content, Value, and Sizing

    Textarea: Markup, Initial Content, Value, and Sizing

    A textarea creates a multiline text field for messages, comments, notes, and other longer entries. Its opening and closing tags surround the initial content, while the name attribute identifies the submitted field and the id connects it to a label and JavaScript.

    The text area HTML pattern also separates three related concepts: text placed between the tags, a placeholder hint, and the control’s current value. Each behaves differently in a form and in JavaScript.

    Create and label a textarea

    Give the control a unique id, then set the label’s for attribute to the same value. Add a name so the field can be included in form submission.

    <label for="message">Message</label>
    <textarea id="message" name="message" rows="5" cols="40"></textarea>

    The label makes the purpose clear and gives users a larger target for focusing the field. The matching for and id attributes establish that connection. The name becomes the field’s submission key, such as message.

    Unlike a void element such as input, a textarea requires both an opening tag and a closing tag. The content belongs between those tags, even when the field starts empty. A field without a name can still be read with JavaScript, but its value is not included in a normal form submission.

    Initial content versus placeholder text

    To supply initial text, write it between the opening and closing textarea tags:

    <textarea id="message" name="message" rows="5" cols="40">Please include your order number.</textarea>

    This text is the field’s initial value. It appears as real content, can be edited immediately, and is submitted if the user leaves it unchanged. Do not use a value attribute as the source of a textarea’s initial text. The content between the tags is the correct HTML mechanism.

    A placeholder is only a temporary instruction or example:

    <textarea id="message" name="message" placeholder="Describe the issue" rows="5" cols="40"></textarea>

    The placeholder disappears when the user types and is not submitted as the field’s value. It should not replace a visible label or carry essential information. Keep the element empty between its tags when you want a placeholder rather than initial content.

    Whitespace between the tags also becomes part of the initial content. Avoid unintended spaces or line breaks if the starting value must match an exact string.

    Read and set the HTML textarea value

    When a form is submitted, the browser sends the textarea’s current value under its name. For the earlier example, a field named message contributes a name-value pair similar to message=The user’s text. The exact encoding depends on the form’s method and encoding settings, but the submitted text comes from the current field value.

    JavaScript reads that current value through the element’s value property:

    const message = document.getElementById("message");
    const currentText = message.value;

    Use the same property to replace or append text:

    message.value = "A new starting message";
    message.value += "\nAdditional details";

    The value property changes as the user types. It therefore represents the current, editable content, not necessarily the text originally written in the HTML. If you need the original markup-defined value, defaultValue represents that starting value. Calling a form reset restores the textarea to its default value.

    Size and resize the control with rows and cols

    The rows and cols attributes set the textarea’s approximate starting dimensions:

    <textarea name="message" rows="8" cols="60"></textarea>

    • rows indicates the approximate number of visible text lines.
    • cols indicates the approximate character width.
    • Neither attribute limits how much text the user can enter.

    Font choice, browser rendering, and CSS can affect the displayed size. For consistent layouts, set the control’s width and height in an external stylesheet rather than relying only on cols and rows. Those HTML attributes still provide useful fallback dimensions and communicate the intended editing area.

    Textareas are commonly resizable by dragging their corner. Set the CSS resize property to vertical when users may change the height but not the width, or to none when resizing should be disabled. Add a maxlength attribute when the field also needs a character limit; sizing alone does not enforce one.

  • HTML nav: How to Mark Up Page Navigation

    HTML nav: How to Mark Up Page Navigation

    The HTML nav element identifies a major group of links that helps users move through a website or page. Use it for primary site navigation, a section menu, breadcrumbs, or an in-page table of contents when the group represents a meaningful navigation landmark.

    The element describes the purpose of a link group, not its visual design. You can style the same semantic structure as a horizontal menu, sidebar, drawer, or mobile navigation without changing the markup.

    What the HTML nav tag Represents

    The HTML nav tag creates a navigation landmark for a collection of important links. Assistive technology can expose that landmark so people can move directly to major navigation areas instead of reading every link in document order.

    Major navigation usually supports a broad movement task, such as moving between the main sections of a site, browsing categories, or jumping between the sections of a long article. Common examples include:

    • A site-wide primary menu with links such as Home, Products, and Contact
    • A section menu for related pages within a documentation or learning area
    • An in-page menu linking to headings in a long article
    • A breadcrumb trail showing the current page’s position in a hierarchy

    Not every group of links needs a nav landmark. An isolated “Read more” link, a pair of related actions, or a small set of footer links may not represent major navigation. Avoid wrapping every isolated link or footer link group in nav without considering its navigational significance. Too many landmarks make page structure harder to scan, especially for people navigating by landmarks.

    How to Mark Up a Primary HTML Navigation Menu

    Place the primary menu near the site header when it represents the main route through the site. A list gives the links a clear group structure, while each anchor provides a specific destination. This complete example contains the nav element, an unordered list, and four links:

    <nav aria-label=”Primary”>

      <ul>

        <li><a href=”/”>Home</a></li>

        <li><a href=”/services/”>Services</a></li>

        <li><a href=”/about/”>About</a></li>

        <li><a href=”/contact/”>Contact</a></li>

      </ul>

    </nav>

    The aria-label gives this landmark a concise name. Keep link text specific and meaningful when read on its own. The nav element does not require a list, but lists are often the clearest choice for a menu because they express that the links belong to one set. CSS can control spacing, alignment, dropdown behavior, and responsive presentation separately from this structure.

    When to Use More Than One nav Element in HTML

    A page can contain several navigation landmarks when each one serves a distinct purpose. For example, a header may contain the primary site menu, while the article contains an in-page contents menu. Both are valid because they help users navigate different scopes.

    Give each landmark a distinct accessible name when more than one appears on the page. For example, use Primary navigation, Section navigation, or On this page rather than assigning the same generic label to every region:

    • Primary navigation: links to the main areas of the website
    • Section navigation: links to related pages within the current area
    • On this page: links to headings in the current document

    A visible heading or text label can also distinguish navigation regions for sighted readers. When the label needs to name the landmark for assistive technology, provide an accessible name such as an appropriate aria-label. Distinct names make landmark lists useful instead of forcing users to inspect each region.

    How Lists, Labels, and Page Structure Clarify Navigation

    Use one list item for each navigation destination, and keep the hierarchy aligned with the information architecture. A nested list can represent a submenu under a parent category. The visual design may hide or reveal that submenu, but the underlying relationships should remain understandable.

    Keep navigation links in a logical order, starting with the most important or frequently used destinations. Use consistent wording between the menu label and the destination heading. For an in-page menu, link text such as Features or Pricing is clearer than repeated labels such as Read more.

    In the phrase HTML navigation, the important distinction is semantic grouping: nav identifies a meaningful route through content, while lists organize the links within that route. Use both when they clarify the page, and leave smaller link groups as ordinary content when adding a landmark would not help users.

  • HTML arrows: Unicode symbols and codes for every direction

    HTML arrows: Unicode symbols and codes for every direction

    HTML arrows use Unicode characters, so each symbol has a decimal character reference and a hexadecimal reference. The examples below pair the rendered arrow with both numeric forms and copyable markup.

    Use a literal Unicode character when your editor and document are saved as UTF-8. Use a numeric reference when you want the source to state the character code explicitly. The numeric form is an HTML arrow code that browsers convert into the same visible symbol.

    Common HTML arrows: left and right symbols

    These are the standard horizontal arrows for navigation, labels, pagination, and directional instructions.

    • ← Left arrow — decimal &#8592;; hexadecimal &#x2190;. Example: <span>←</span> or <span>&#8592;</span>.
    • → Right arrow — decimal &#8594;; hexadecimal &#x2192;. Example: <span>→</span> or <span>&#8594;</span>.
    • ↔ Left-right arrow — decimal &#8596;; hexadecimal &#x2194;. Example: <span>↔</span> or <span>&#8596;</span>.

    How do you add an up arrow in HTML?

    To insert an arrow in HTML, use its literal Unicode character or numeric reference. An up arrow in HTML commonly indicates sorting, expansion, elevation, or movement toward the beginning of a list. A down arrow in HTML can indicate the opposite direction.

    • ↑ Up arrow — decimal &#8593;; hexadecimal &#x2191;. Example: <span>↑</span> or <span>&#8593;</span>.
    • ↓ Down arrow — decimal &#8595;; hexadecimal &#x2193;. Example: <span>↓</span> or <span>&#8595;</span>.
    • ↗ Up-right arrow — decimal &#8599;; hexadecimal &#x2197;. Example: <span>↗</span> or <span>&#8599;</span>.
    • ↘ Down-right arrow — decimal &#8600;; hexadecimal &#x2198;. Example: <span>↘</span> or <span>&#8600;</span>.

    Double and long HTML arrow code examples

    Double arrows suit logical relationships, transformations, and two-way actions. Long arrows are useful when the symbol needs more visual emphasis in a heading or diagram label.

    • ⇐ Left double arrow — decimal &#8656;; hexadecimal &#x21D0;. Example: <span>⇐</span>.
    • ⇒ Right double arrow — decimal &#8658;; hexadecimal &#x21D2;. Example: <span>⇒</span>.
    • ⇔ Left-right double arrow — decimal &#8660;; hexadecimal &#x21D4;. Example: <span>⇔</span>.
    • ⟵ Long left arrow — decimal &#10229;; hexadecimal &#x27F5;. Example: <span>⟵</span>.
    • ⟶ Long right arrow — decimal &#10230;; hexadecimal &#x27F6;. Example: <span>⟶</span>.
    • ⟷ Long left-right arrow — decimal &#10231;; hexadecimal &#x27F7;. Example: <span>⟷</span>.

    How do you use an arrow in HTML with UTF-8?

    Save the HTML document as UTF-8 and declare that encoding in the document head with <meta charset=”UTF-8″>. This allows literal arrow characters to be stored and displayed consistently when the selected font supports them.

    Literal-character markup looks like <p>Next →</p>. Numeric-reference markup looks like <p>Next &#8594;</p> or <p>Next &#x2192;</p>. All three forms render as “Next →”. Decimal and hexadecimal references are interchangeable; choose the format that best matches your project’s coding conventions.

    Use an arrow as text when it carries meaning, and include a word label when direction alone could be unclear. Unicode arrow characters are text glyphs; they are not the same as arrows drawn with CSS borders or other visual styling.

  • Submit Button in HTML Forms: Syntax, Data, and Examples

    Submit Button in HTML Forms: Syntax, Data, and Examples

    A submit button activates its associated form and asks the browser to send the form’s successful controls. The clearest syntax is an explicit button element with type=”submit”, a label, and, when needed, a name and value.

    The examples below show a working form, the equivalent input syntax, and the data each control contributes when activated.

    Submit button: create a complete HTML form

    Place the button between the opening and closing form tags. Give the form an action URL and a method so the browser knows where and how to send the data.

    Complete button example: <form action=”/signup” method=”post”> <label for=”email”>Email address</label> <input id=”email” name=”email” type=”email” required /> <button type=”submit”>Sign up</button> </form>

    When the visitor activates “Sign up,” the browser sends the email field to /signup. With method=”post”, the data normally goes in the request body. With method=”get”, it is appended to the action URL as a query string.

    Always write type=”submit” when the button is intended to submit the form. A button inside a form defaults to the submit behavior if its type is omitted, but an explicit type makes the intent clear and prevents accidental submissions when the form changes.

    Compare an HTML submit button with an input control in complete forms

    An HTML submit button can contain text and other permitted button content. Its visible label is the content between the opening and closing tags. An input submit control is a void element, so its label comes from the value attribute.

    Complete button-element form: <form action=”/search” method=”get”> <label for=”term”>Search</label> <input id=”term” name=”q” type=”search” /> <button type=”submit”>Search the site</button> </form>

    Complete input-element form: <form action=”/search” method=”get”> <label for=”term”>Search</label> <input id=”term” name=”q” type=”search” /> <input type=”submit” value=”Search the site” /> </form>

    Both forms send the same search field, such as q=html. Use button when you need richer content or several distinct actions. Use input type=”submit” for a simple text-only control.

    What a form submit button sends: name, value, and disabled state

    A form submit button sends its own name-value pair only when it has a name, a value, and is the button that activated the form. The button’s visible text is not submitted automatically.

    <form action=”/orders” method=”post”> <input name=”order_id” value=”4821″ /> <button type=”submit” name=”action” value=”save”>Save order</button> <button type=”submit” name=”action” value=”preview”>Preview order</button> </form>

    If “Save order” is activated, the request includes order_id=4821 and action=save. If “Preview order” is activated, the action value is preview instead. This lets the server distinguish multiple actions in one form.

    A disabled form submit button cannot be activated and does not contribute its name or value to submitted data. The disabled attribute is useful when an action is temporarily unavailable: <button type=”submit” name=”action” value=”delete” disabled>Delete order</button>. A disabled field elsewhere in the form is also omitted from the request.

    Choose a button with type=”submit” or type=”button”, inside or outside a form

    Use type=”button” for a control that should not submit the form, such as a button that opens a panel, adds a row, or runs client-side behavior. Without that type, a button inside the form is a submit control by default.

    <form action=”/profile” method=”post”> <input name=”display_name” /> <button type=”button”>Show character count</button> <button type=”submit”>Save profile</button> </form>

    The first button does not submit; the second does. A button outside the form can still be associated with it through the form attribute, whose value must match the form’s id.

    <form id=”profile-form” action=”/profile” method=”post”> <input name=”display_name” /> </form> <button type=”submit” form=”profile-form” name=”action” value=”save”>Save profile</button>

    This outside button submits profile-form and contributes action=save. The form attribute is useful when layout requirements place the controls alongside, rather than inside, the form.

  • HTML aside element: Meaning, Markup, and CSS

    HTML aside element: Meaning, Markup, and CSS

    An HTML aside marks content that is tangentially related to the surrounding content, not content merely positioned at the side of a screen. Its meaning comes from its relationship to the nearest relevant section, article, or page.

    Use the element when the material can be removed without breaking the main narrative, while still offering useful context. Ordinary CSS can then place it beside, below, or within that content.

    What does the aside element define?

    The aside element defines a complementary section whose connection to the main content is useful but not essential. “Tangentially related” means the content supports, explains, or extends the subject without being part of its central sequence.

    Appropriate examples include a glossary note in a technical article, a pull quote, an author biography, related resources, background facts, or a short explanation of a term used in the surrounding section. A page-level related-links panel or secondary information box can also be an aside.

    Do not use aside solely because a block appears visually on the side of the page. A sidebar created for layout may contain an aside, but position alone does not establish the element’s meaning. Information essential to the main instructions, argument, or process belongs in the primary content instead.

    HTML aside: Article-local versus page-level placement

    An article-local aside belongs inside the article it supports. For example, an article about CSS grid might contain an aside defining the gap property, listing related grid concepts, or highlighting a supporting fact. The relationship is specifically to that article.

    A page-level aside sits outside the article, usually as a sibling to it within main. It can provide related reading, an author profile, a secondary navigation group, or a complementary signup prompt for the page as a whole. If a page contains several articles, a shared related-links panel may be more appropriately associated with the page than with any single article.

    This distinction is semantic rather than visual. An article-local aside may render as an inset box, while a page-level aside may appear below the article on a narrow screen. Both positions are valid when the content relationship is correct.

    Aside element HTML: A complete markup example

    The following example shows both placements. The first aside is part of the article; the second is related to the page-level content around that article.

    Example: <main> <article> <h2>Understanding grid gaps</h2> <p>The gap property sets space between grid tracks.</p> <aside> <h3>Related term</h3> <p>A grid track is a row or column in the grid.</p> </aside> </article> <aside> <h2>Related guides</h2> <ul> <li>Flexible grid columns</li> <li>Responsive layout basics</li> </ul> </aside> </main>

    Keep the primary information in the article or main content. Give an aside a useful heading when its purpose is not immediately clear, and use a list or other appropriate element for the content inside it.

    CSS aside styling: How to build sidebars and callouts

    The aside element has no mandatory visual position, width, color, or layout behavior. Style it with the same CSS layout tools used for other elements. Contextual selectors help distinguish an article-local callout from a page-level sidebar.

    A general treatment might be:

    aside { padding: 1rem; border: 1px solid #cbd5e1; background: #f8fafc; } article > aside { margin-block: 1.5rem; border-inline-start: 0.25rem solid #64748b; }

    To create a wide-screen sidebar for the page-level example, use a grid on the containing main element:

    main { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 2rem; } main > aside { align-self: start; } @media (max-width: 48rem) { main { grid-template-columns: 1fr; } }

    This layout places a direct child aside beside the article on larger screens and lets it stack naturally below the article on smaller screens. The HTML relationship remains unchanged, so the same markup supports sidebars, inline callouts, or full-width complementary sections.