Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:19:39+00:00 2026-05-23T15:19:39+00:00

Tackling the problem of annotating HTML markup and storing marks in the markup itself,

  • 0

Tackling the problem of annotating HTML markup and storing marks in the markup itself, the <mark> element came across as a tentative solution. Marking inline:

<p>The fox <mark>jumped over</mark> the lazy dog.</p>

I want to extend this idea towards marking (highlighting) arbitrary pieces of text in the document. Unfortunately, following this approach to mark, say, across paragraphs, would generate invalid HTML (<mark> expects phrasing content) and possibly break the DOM hierarchy:

<mark><p>Red Green Blue.</p> <p>Magenta, Cyan,</mark> Black</p>

Although a smart parser might translate the above into:

<p><mark>Red Green Blue.</mark></p> <p><mark>Magenta, Cyan,</mark> Black</p>

it doesn’t preserve the fact there was a single mark spanning a paragraph and a fragment of a second paragraph, not two marks!

What is the best, possibly semantic way of doing this without breaking the DOM hierarchy? I seek to query this data through DOM/JS APIs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:19:40+00:00Added an answer on May 23, 2026 at 3:19 pm

    The only viable solution, markup-wise, is to follow the example of your smart parser. Assuming the highlighting information (or rather, the information that the original highlight spanned across paragraphs) is only required for machine use, one can then append a custom data attribute grouping these separate mark elements:

    <p><mark data-mark-group="1">Red Green Blue.</mark></p> <p><mark data-mark-group="1">Magenta, Cyan,</mark> Black</p>
    

    This information could also potentially be used with some sort of JS to indicate highlights across paragraphs in style as well, but I’ll leave that as an exercise to the reader.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm tackling an interesting machine learning problem and would love to hear if anyone
This is possibly a problem with possibly no optimal solution. Suppose I have a
In all projects I've done through the years I never came across a requirement
I am tackling relativeLayout problem in my application. I take one image and button.
Tackling a strange scenario here. We use a proprietary workstation management application which uses
I'll be tackling writing a custom date validation class tomorrow for a meeting app
I think my problem is best described in code: #include <stdio.h> struct Foo; extern
Sort of a mongo noob, and I have a feeling I am tackling this
I have been asked to come up with a solution which would allow our
I'm new to programming and I'm tackling arrays. I thought I had multi-dimensional arrays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.