Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

You Only Need 12 Lines of CSS for a Clean, Attractive Website

A 12-declaration CSS baseline can center a readable text column, scale type, keep images inside their space, and adjust link styling. Here is what each rule does, which values to change, and what to check for accessibility.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A short stylesheet can give a plain HTML page a readable text column, comfortable type, and images that stay inside their space. The baseline in this guide is twelve CSS declarations, and it works as a starting point rather than a finished design. It comes from a How-To Geek walkthrough by author Bobby Jack, republished on Yahoo Tech and dated 2026. The author’s own caveat is the right way to read it: “These styles will not necessarily all apply to your design.”

The complete baseline

The original snippet packs several declarations onto each physical line. The version below contains the same twelve declarations, one per line, so each one is easy to find and change.

As an Amazon Associate I earn from qualifying purchases.

html {
  box-sizing: border-box;
  max-width: 70ch;
  margin: auto;
  font-size: 1.25em;
  color: #333;
  line-height: 1.4;
}
* { box-sizing: inherit; }
h1, h2, h3, h4, h5, h6 { font-family: sans-serif; }
img { max-width: 100%; height: auto; }
a:link { text-decoration: none; }
a:hover { text-decoration: underline; }

The count matters because the article’s “12 lines” is really twelve declarations. Compact formatting can make the stylesheet look shorter than it is, and a reader who copies only the first six lines will miss half the rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How each group of rules works

Sizing with border-box

box-sizing: border-box on the html element means that a declared width includes padding and borders. Without it, adding padding to an element with a set width makes the element wider than you specified, which is a common source of layout surprises. The universal selector * { box-sizing: inherit; } passes that setting down so every element uses the same model. Because the rule is inherited, you only need to change it in one place if you later want a different model for a particular component.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

The reading column

max-width: 70ch caps the width of the html element, and margin: auto centres it when the browser window is wider than that cap. The article cites typography guidance of 45 to 75 characters per line, which it reports from How-To Geek’s 2026 reference material. Treat that range as a commonly cited guideline rather than a measured standard. The ch unit is based on the width of the “0” character in the current font, so it approximates a character count. With a variable-width font, the number of characters that actually fit will vary from line to line.

The snippet applies the width cap to html rather than to a wrapper element, and it does not reset the browser’s default body margin. Centring behaves as expected in current browsers in the author’s example, but if your page has a body with its own padding or a fixed-width header, you will need a wrapper element and a test of its own.

Type size and line height

font-size: 1.25em scales text relative to the browser’s base size. The article’s example takes the common 16px default and produces 20px. The result depends on each reader’s browser settings, so 20px is an illustration, not a fixed value. line-height: 1.4 adds vertical space between lines, which the article presents as a compromise. The author says the best value depends on the typeface, line length, and paragraph content, so the 1.4 figure is a reasonable place to begin, not a rule.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Headings

The rule h1, h2, h3, h4, h5, h6 { font-family: sans-serif; } sets headings to a sans-serif face while the body keeps the browser’s default serif. This creates visual contrast between headings and text. It is a stylistic choice that the article offers as one option. Nothing about HTML or accessibility requires it, and if your brand uses a different typeface, change the family rather than keeping the generic one.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Images

img { max-width: 100%; height: auto; } does two jobs. The width limit stops an image from running past its container when the column is narrower than the image’s natural size. The height: auto value keeps the image’s proportions when it scales down, so it is not squashed. Together they handle most responsive image overflow in simple pages. They do not control how an image is cropped, and they do not prevent layout shift before the image loads, which is a separate concern covered by setting explicit dimensions in the HTML.

Links

The last two rules remove the underline from links at rest and restore it on hover. The author notes that links keep the browser’s default blue colour, and that keyboard users still see the browser’s default focus outline. That focus outline is the most important thing to keep. Removing underlines is a design decision that makes links harder to spot in running text, so check whether a reader can still tell a link from ordinary text before you ship the change.

Which values to change first

The twelve declarations are not equally likely to need adjustment. The table below lists the values most often worth revisiting and the circumstances that justify changing them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Declaration Starting value in the article Change it when
max-width on html 70ch Your content is code, tables, or wide forms that need more room, or your typeface is very wide or very narrow.
font-size 1.25em (20px from a 16px base in the article’s example) Your body text is dense, or your audience commonly uses a larger or smaller browser text size.
line-height 1.4 Paragraphs are long or set in a condensed face, which may call for more or less leading.
color #333 Your page uses a different palette, or you need a stronger contrast value for your text and background.
font-family on headings sans-serif Your typography system names a specific typeface for headings.
text-decoration on links none at rest; underline on hover Links need to be identifiable without relying on colour alone, which is common in body copy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Applying the baseline to a page

The following sequence applies the rules to a simple HTML document and checks that they work as intended.

  1. Create a file named index.html with a head containing a title element and a body containing a few headings, paragraphs, one image, and two or three links.
  2. Place the twelve declarations inside a style element in the head, or save them as style.css and link that file with a link element. Either works for a single page.
  3. Open the file in a browser. In Chrome or Edge, use the DevTools panel (F12 or Ctrl+Shift+I) and select the html element in the Elements tab to confirm that the computed max-width is about 70 characters of the current font.
  4. Widen and narrow the browser window. The text column should stay centred and should stop widening once it reaches the cap. An image wider than the column should shrink rather than overflow.
  5. Hover over a link and confirm that the underline appears. Then press Tab to move focus through the links and confirm that the browser’s focus outline is still visible.
  6. Change the browser’s default text size in its settings and reload. The page should remain readable, and the headings and body text should scale together.

Accessibility checks the article does not perform

The article reports two contrast ratios it calculated. Dark grey #333 on white is 12.63:1, and black on white is 21:1. Both figures are well above the 4.5:1 minimum that the WCAG 2 standard sets for normal body text at its AA level, so the default colour choice is safe for most text. The article also mentions a 7:1 figure without naming the conformance level or the text conditions it applies to. In WCAG 2, 7:1 is the enhanced (AAA) threshold for normal text, but the source does not make that distinction, so consult the WCAG text directly before treating 7:1 as a requirement for your project.

The article is a walkthrough, not a browser test, a user study, or an accessibility audit. Before publishing a site built on these rules, check focus visibility with the keyboard, confirm link identification without underlines, and test the page with your own content, including long words and wide tables, since these are the cases the twelve lines do not address.

Where the baseline ends

The stylesheet is a base for simple documents such as a personal page, a short article, or a project README converted to HTML. It does not style navigation, forms, code blocks, tables, dark mode, or print output, and it leaves the browser’s default body margin in place. Once those components appear, add rules for them in the same file so the spacing and type scale stay consistent. The safest habit is to keep the twelve declarations, change only the values that your content and audience require, and treat every change as a deliberate decision rather than a default that came with the snippet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.