summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-08 12:41:42 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-08 12:43:49 +0200
commit8f0a48ef23d64ee5e512a6f6a316c2bde22637cc (patch)
tree76359803c8e05ba258212b15e0a960898435cd08
parent3dc82d2fa5f3b3441cb180f992ad0b25882e4e51 (diff)
downloadserenity-8f0a48ef23d64ee5e512a6f6a316c2bde22637cc.zip
LibWeb: Make default CSS font settings match other browsers better
Let's make 16px the default font size instead of 10px. This makes our layout results match those of other engines in many more cases. Also make the h1-h6 element styles use relative (em) font sizes, also matching other browsers.
-rw-r--r--Userland/Libraries/LibWeb/CSS/ComputedValues.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Default.css32
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp6
3 files changed, 32 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
index 69d912ef83..ecb9c23134 100644
--- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h
+++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
@@ -15,7 +15,7 @@ namespace Web::CSS {
class InitialValues {
public:
- static float font_size() { return 10; }
+ static float font_size() { return 16; }
static int font_weight() { return 400; }
static CSS::FontVariant font_variant() { return CSS::FontVariant::Normal; }
static CSS::Float float_() { return CSS::Float::None; }
diff --git a/Userland/Libraries/LibWeb/CSS/Default.css b/Userland/Libraries/LibWeb/CSS/Default.css
index 8319932a48..30ef6d8fde 100644
--- a/Userland/Libraries/LibWeb/CSS/Default.css
+++ b/Userland/Libraries/LibWeb/CSS/Default.css
@@ -11,13 +11,37 @@ body {
margin: 8px;
}
-h1,
+h1 {
+ font-size: 2em;
+ margin: 0.67em 0;
+}
+
h2 {
- font-family: Pebbleton;
- font-size: 14px;
- font-weight: bold;
+ font-size: 1.5em;
+ margin: 0.83em 0;
+}
+
+h3 {
+ font-size: 1.17em;
+ margin: 1em 0;
+}
+
+h4 {
+ margin: 1.33em 0;
+}
+
+h5 {
+ font-size: 0.83em;
+ margin: 1.67em 0;
+}
+
+h6 {
+ font-size: 0.67em;
+ margin: 2.33em 0;
}
+h1,
+h2,
h3,
h4,
h5,
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index 7f7a096efa..2e4931b45a 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -855,7 +855,7 @@ void StyleComputer::compute_defaulted_values(StyleProperties& style, DOM::Elemen
float StyleComputer::root_element_font_size() const
{
- constexpr float default_root_element_font_size = 10;
+ constexpr float default_root_element_font_size = 16;
auto const* root_element = m_document.first_child_of_type<HTML::HTMLHtmlElement>();
if (!root_element)
@@ -921,7 +921,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
bool bold = weight > Gfx::FontWeight::Regular;
- float font_size_in_px = 10;
+ float font_size_in_px = 16;
if (font_size->is_identifier()) {
switch (static_cast<IdentifierStyleValue const&>(*font_size).id()) {
@@ -930,7 +930,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
case CSS::ValueID::Small:
case CSS::ValueID::Medium:
// FIXME: Should be based on "user's default font size"
- font_size_in_px = 10;
+ font_size_in_px = 16;
break;
case CSS::ValueID::Large:
case CSS::ValueID::XLarge: