Implement HTML5's <mark> tag

RESOLVED FIXED in mozilla2.0b1



10 years ago
2 months ago


(Reporter: ivan.enderlin, Assigned: Ms2ger)


(Blocks 1 bug, {dev-doc-complete, html5})

Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)




(2 attachments, 4 obsolete attachments)



10 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3
Build Identifier: 

The HTML 5 draft recommendation describes the <mark> element as follow:
"The <mark> element represents a run of text in one document marked or
highlighted for reference purposes, due to its relevance in another context.
When used in a quotation or other block of text referred to from the prose, it
indicates a highlight that was not originally present but which has been added
to bring the reader's attention to a part of the text that might not have been
considered important by the original author when the block was originally
written, but which is now under previously unexpected scrutiny. When used in the
main prose of a document, it indicates a part of the document that has been
highlighted due to its likely relevance to the user's current activity.".

More examples at

The draft does not precise a default style.

It is a semantic element, with generic HTML properties.

Reproducible: Always

Comment 1

10 years ago
You shouldn't need the new nsHTMLMarkElement.cpp, and indeed it doesn't seem like you're actually using it. The change to nsHTMLTagList.h ensures that we instantiate an nsHTMLSpanElement, which seems to be exactly what we want.
Does the <mark> element need un-<span>-like exposure to accessibility APIs?

Comment 4

10 years ago
@Jonas: Yes, the nsHTMLTagList declaration asserts to use the nsHTMLSpanElement. Should it be suffisant to do that ? I have note that also the <abbr> element is recognized like a <span> (test:

@Henri: I think no. I have looked for in the HTML 5 specification and I didn't find anything that is on the subject, but I may be wrong :-).
Perhaps the "Find Again" command should cycle through <mark> elements when the user hasn't entered a search string into the "Find" bar.

Comment 6

10 years ago
Definitively. I am currently working on this feature.

Comment 7

9 years ago
(In reply to comment #0)
> The draft does not precise a default style.

Actually, it does.
Not a parser bug, AFAICT.
Component: HTML: Parser → DOM
Ever confirmed: true
QA Contact: parser → general


9 years ago
Keywords: html5
Version: unspecified → Trunk

Comment 9

9 years ago
Would a patch for adding "mark { background: yellow; color: black; }" to html.css be better than not having any support at all, where the alternative is to implement everything (is there anything other than CSS and DOM changes to be done?) related to the "mark" element at a later date?

It could be noted that similar actions has already been taken for several other HTML5 elements, in bug 559284.
Why go for a half-assed implementation. There is a patch that is almost finished. Why not finish and land that instead.

Just remove the changes to nsGenericHTMLElement.h and remove the new nsHTMLMarkElement.* files. And add the html.css change in comment 9.

Then add a reftest checking that the default rendering is ok and that |document.createElement("mark") instanceof HTMLElement| is true
|document.createElement("mark") instanceof HTMLUnknownElement| is false

Comment 11

9 years ago
Well, considering the patch is called "Patch 0.1: Early draft" and haven't been updated since early 2009, I assumed it was pretty "dead" and perhaps out of date. Still, the full implementation is of course what we want to do/have.

Comment 12

9 years ago
Oh, and to avoid misunderstandings, this is not me taking on the task to update the patch. If it was as easy as just uploading a new version of the file, I probably could, but those patch/building instructions look too advanced for me, and I don't have the time to learn how to do it properly right now.

Comment 13

9 years ago
The patch is not dead. I'm just waiting 2 days free to work on this patch…

If it is too easy as Jonas said, I can make it in June maybe (I hope).
Posted patch Patch v2 (obsolete) — Splinter Review
Updated to Jonas' comments. Ivan, I hope you don't mind.

Note that |document.createElement("mark") instanceof HTMLUnknownElement| isn't false. Apparently, all HTML elements implement HTMLUnknownElement.
Attachment #446980 - Flags: review?(jonas)
Posted patch Editor patch v1 (obsolete) — Splinter Review
Turns out I needed to tell editor about it too... This change is covered by the following existing tests

Attachment #447511 - Flags: review?(timeless)

Comment 17

9 years ago
i have a feeling this is going to conflict with bug 562008.

Comment 18

9 years ago
@Ms2ger It's ok, I don't mind :-). I prefere to see this patch going further instead of resting in peace ;-).
hmm, Ms2ger, your patch makes <mark> be an HTMLSpanElement. I don't think we want <mark> to be an HTMLSpanElement (even if that makes <mark> using HTMLElement interface) ?

IOW, document.createElement('mark').constructor should return HTMLElement, not HTMLSpanElement.

Comment 20

9 years ago
@Mounir: That's what I thought at the begining, but in Gecko, the majority of semantic elements are reconized as HTMLSpanElement.
(In reply to comment #20)
> @Mounir: That's what I thought at the begining, but in Gecko, the majority of
> semantic elements are reconized as HTMLSpanElement.

Indeed. Anyway, this is going to be fixed with bug 562008.
@Ms2ger: could you open a follow-up depending on bug 562008 and put me in CC ?
Blocks: 568509
Merged to tip. r=jonas
Attachment #446980 - Attachment is obsolete: true
Blocks: 573357


9 years ago
Depends on: 573377
Posted patch Editor patch v2 (obsolete) — Splinter Review
timeless, could you review this patch as well? Thanks!
Attachment #447511 - Attachment is obsolete: true
Attachment #452587 - Flags: review?(timeless)
Attachment #447511 - Flags: review?(timeless)


9 years ago
Attachment #452587 - Flags: review?(timeless) → review+
This patch contains attachment 449613 [details] [diff] [review] (r=jonas) and attachment 452587 [details] [diff] [review] (r=timeless), as well as attachment 447778 [details] [diff] [review] from bug 568509 (r=jonas).
Attachment #449613 - Attachment is obsolete: true
Attachment #452587 - Attachment is obsolete: true


9 years ago
Keywords: checkin-needed
Assignee: nobody → Ms2ger
Assuming this needs to be documented, so adding dev-doc-needed.
Last Resolved: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a6
Documented as:
(I'll update it once bug 568509 land).

As I cannot change the keyword dev-doc-needed to dev-doc-complete, if somebody could do it, it would be nice.


9 years ago
Flags: in-testsuite+
Component: DOM → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.