liveBook · Manning

Font-size property

As explained in Build a Website with ChatGPT

The CSS font-size property specifies the size of text rendered by an element.

The CSS font-size property sets how large an element’s text appears. A type size is the relative size of each character. Sizes are commonly written in pixels, shortened to px; regular page text defaults to 16px. section 3.2.3

Set a text size

Write `font-size: 20px;` in a CSS rule to make its text larger than the usual 16px. If you ask ChatGPT to generate the CSS, you can be just as specific: “Style the web page tagline with a font size of 24px.” section 3.2.3

Headings often need different sizes from paragraph text. The defaults are 32px for an `<h1>`, 24px for an `<h2>`, and about 18.2px for an `<h3>`. If those sizes do not suit your page, specify the size you want for each heading level in your prompt. section 3.2.7

.entry-text {
    font-size: 20px;
}

This CSS rule sets text with the `entry-text` class to 20px—an example of changing the size of one kind of page text. section 5.4

For a personal home page, request separate sizes for the title, subtitle, second-level headings, and regular text. Ask for HTML and CSS in separate files; save them as `index.html` and `styles.css`, or use the CSS filename shown in the HTML link, and keep them in the same folder. section 3.2.8

To fine-tune generated CSS, change the number in a font-size value and keep its `px` unit. If text feels cramped or hard to read, try increasing it by a pixel or two. You may also need to adjust the page’s maximum width when you change text size. section 4.4

For a more accessible size measurement, consider `rem` instead of `px`. A rem is relative to the default font size set in the reader’s browser; by default, 1rem equals 16px, so 20px equals 1.25rem. Start with a readable size, then adjust it to suit the page. section 4.4

How Build a Website with ChatGPT covers it

How deep it goes
Defines pixel-based syntax, supplies heading defaults and editing tips, and introduces rem conversions without exploring CSS internals.
Examples
Uses a 24px tagline prompt, heading-size comparisons, and a 20px entry-text CSS rule.
What it assumes
Introduces pixels, the 16px regular-text default, and CSS font-size syntax without assuming prior coding knowledge.
What you can do after
Operate/configure it by specifying sizes in a ChatGPT prompt or changing font-size values in generated CSS.
How it connects
Connects font-size to CSS, HTML headings, page width, and rem units.

Also explained in

Compare how 9 books explain font-size property →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Website with ChatGPT. The section links point to the parts of the book it draws on.