Commit 09019a8e authored by Mark Otto's avatar Mark Otto Committed by Mark Otto
Browse files

Set explicit text-align on <body> element so we can use inherit to override...

Set explicit text-align on <body> element so we can use inherit to override the default <th> text-align value
parent caa7117e
Showing with 7 additions and 3 deletions
+7 -3
...@@ -24,7 +24,7 @@ The `<html>` and `<body>` elements are updated to provide better page-wide defau ...@@ -24,7 +24,7 @@ The `<html>` and `<body>` elements are updated to provide better page-wide defau
- The `box-sizing` is globally set on every element—including `*:before` and `*:after`, to `border-box`. This ensures that the declared width of element is never exceeded due to padding or border. - The `box-sizing` is globally set on every element—including `*:before` and `*:after`, to `border-box`. This ensures that the declared width of element is never exceeded due to padding or border.
- No base `font-size` is declared on the `<html>`, but `16px` is assumed (the browser default). `font-size: 1rem` is applied on the `<body>` for easy responsive type-scaling via media queries while respecting user preferences and ensuring a more accessible approach. - No base `font-size` is declared on the `<html>`, but `16px` is assumed (the browser default). `font-size: 1rem` is applied on the `<body>` for easy responsive type-scaling via media queries while respecting user preferences and ensuring a more accessible approach.
- The `<body>` also sets a global `font-family` and `line-height`. This is inherited later by some form elements to prevent font inconsistencies. - The `<body>` also sets a global `font-family`, `line-height`, and `text-align`. This is inherited later by some form elements to prevent font inconsistencies.
- For safety, the `<body>` has a declared `background-color`, defaulting to `#fff`. - For safety, the `<body>` has a declared `background-color`, defaulting to `#fff`.
## Native font stack ## Native font stack
......
...@@ -48,6 +48,8 @@ article, aside, dialog, figcaption, figure, footer, header, hgroup, main, nav, s ...@@ -48,6 +48,8 @@ article, aside, dialog, figcaption, figure, footer, header, hgroup, main, nav, s
// //
// 1. Remove the margin in all browsers. // 1. Remove the margin in all browsers.
// 2. As a best practice, apply a default `background-color`. // 2. As a best practice, apply a default `background-color`.
// 3. Set an explicit initial text-align value so that we can later use the
// the `inherit` value on things like `<th>` elements.
body { body {
margin: 0; // 1 margin: 0; // 1
...@@ -56,6 +58,7 @@ body { ...@@ -56,6 +58,7 @@ body {
font-weight: $font-weight-base; font-weight: $font-weight-base;
line-height: $line-height-base; line-height: $line-height-base;
color: $body-color; color: $body-color;
text-align: left; // 3
background-color: $body-bg; // 2 background-color: $body-bg; // 2
} }
...@@ -304,8 +307,9 @@ caption { ...@@ -304,8 +307,9 @@ caption {
} }
th { th {
// Matches default `<td>` alignment // Matches default `<td>` alignment by inheriting from the `<body>`, or the
text-align: left; // closest parent with a set `text-align`.
text-align: inherit;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment