w3c / w3c/editing

Should we propose "::caret" pseudo-element to CSS WG?

Open
#158 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
202
Forks
43
PR merge metrics
No merged PRs in 30d

Description

::caret pseudo-element

Proposal:

::caret pseudo-element is used for rendering "caret-shape:bar", rendering engine uses "font-*" properties to determine height of caret, from font-size and font-family, and width from font-weight and slanted from font-style.

Motivation

::caret pseudo-element allows us:

  • Solves #70, height of empty element is specified by ::caret pseudo-element. When editable element gets focus, we can enlarge the element to hold a character having style specified by ::caret pseudo-element rather than height of element.
<style>
::caret { font-size: 20px }
</style>
Below cE should have height for "font-size: 20px" when its get focus.
<div style="height: 0px" contenteditable>
   <span style="font-size: 20px;">foo</span>
</div>
  • Font menu; rather than inserting an empty SPAN with inline style, we set properties of ::caret pseudo-element for matching caret shape to next inserted characters.
  • Render caret as last typing style; rather than leaving empty element, we can remove empty element, e.g. when user removes character a from <b>a<;/b>, we want to remove <b></b> but caret shape should be thick since next typed character should have bold style.

Note: Term "height" and "width" assumes horizontal writing-mode, on vertical-mode height and width are swapped.

[1] https://drafts.csswg.org/css-ui-4/#caret-shape

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the proposed ::caret pseudo-element behavior in this issue and the linked CSS UI 4 caret-shape reference. Determine whether the editing task force should forward the proposal to the CSS Working Group, and record the resulting decision or next steps.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.