diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp
index a8e013822d1..6fc228f4f5e 100644
--- a/Libraries/LibWeb/Editing/Commands.cpp
+++ b/Libraries/LibWeb/Editing/Commands.cpp
@@ -1281,6 +1281,23 @@ bool command_remove_format_action(DOM::Document& document, String const&)
return true;
}
+// https://w3c.github.io/editing/docs/execCommand/#the-strikethrough-command
+bool command_strikethrough_action(DOM::Document& document, String const&)
+{
+ // If queryCommandState("strikethrough") returns true, set the selection's value to null.
+ if (document.query_command_state(CommandNames::strikethrough)) {
+ set_the_selections_value(document, CommandNames::strikethrough, {});
+ }
+
+ // Otherwise set the selection's value to "line-through".
+ else {
+ set_the_selections_value(document, CommandNames::strikethrough, "line-through"_string);
+ }
+
+ // Either way, return true.
+ return true;
+}
+
// https://w3c.github.io/editing/docs/execCommand/#the-stylewithcss-command
bool command_style_with_css_action(DOM::Document& document, String const& value)
{
@@ -1385,6 +1402,12 @@ static Array const commands {
.command = CommandNames::removeFormat,
.action = command_remove_format_action,
},
+ // https://w3c.github.io/editing/docs/execCommand/#the-strikethrough-command
+ CommandDefinition {
+ .command = CommandNames::strikethrough,
+ .action = command_strikethrough_action,
+ .inline_activated_values = { "line-through"sv },
+ },
// https://w3c.github.io/editing/docs/execCommand/#the-stylewithcss-command
CommandDefinition {
.command = CommandNames::styleWithCSS,
diff --git a/Libraries/LibWeb/Editing/Commands.h b/Libraries/LibWeb/Editing/Commands.h
index 702582c1711..3804f28c5df 100644
--- a/Libraries/LibWeb/Editing/Commands.h
+++ b/Libraries/LibWeb/Editing/Commands.h
@@ -44,6 +44,7 @@ bool command_insert_linebreak_action(DOM::Document&, String const&);
bool command_insert_paragraph_action(DOM::Document&, String const&);
bool command_italic_action(DOM::Document&, String const&);
bool command_remove_format_action(DOM::Document&, String const&);
+bool command_strikethrough_action(DOM::Document&, String const&);
bool command_style_with_css_action(DOM::Document&, String const&);
bool command_style_with_css_state(DOM::Document const&);
diff --git a/Tests/LibWeb/Text/expected/Editing/execCommand-strikethrough.txt b/Tests/LibWeb/Text/expected/Editing/execCommand-strikethrough.txt
new file mode 100644
index 00000000000..70ac34e0436
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/Editing/execCommand-strikethrough.txt
@@ -0,0 +1,4 @@
+Div contents: "foobar" state: false selection: #document 0 #document 0
+Div contents: "foobar" state: true selection: #text 0 #text 3
+Div contents: "foobar" state: true selection: #text 0 #text 3
+Div contents: "foobar" state: false selection: #text 0 #text 3
diff --git a/Tests/LibWeb/Text/input/Editing/execCommand-strikethrough.html b/Tests/LibWeb/Text/input/Editing/execCommand-strikethrough.html
new file mode 100644
index 00000000000..7c37150124a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/Editing/execCommand-strikethrough.html
@@ -0,0 +1,34 @@
+
+