Home >Development Tools >VSCode >How to set the background and font when creating an HTML project with vscode
How to use VSCode to set the background and font background settings for HTML projects: Create a new HTML file and add a background color definition in the CSS style sheet, such as body {background-color: #f0f0f0;}. Font settings: Load a web font, import it into an HTML page, and specify the font using the font-family property in a CSS style sheet, for example body {font-family: 'Roboto', sans-serif;}.
How to use VSCode to set the background and font for an HTML project
Background settings
<link>
tag in the <head>
tag to link to an external CSS style sheet . For example: <code class="html"><head> <link rel="stylesheet" href="style.css"> </head></code>
<code class="css">body { background-color: #f0f0f0; }</code>
Font Settings
<link>
tag inside the <head>
tag: <code class="html"><head> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"> </head></code>
font-family
property to specify your font. For example: <code class="css">body { font-family: 'Roboto', sans-serif; }</code>
font-size
, font-weight
and font-style
. Sample HTML and CSS code
Here is a sample HTML and CSS code to set the background and font:
<code class="html"><!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <h1>标题</h1> <p>正文</p> </body> </html></code>
<code class="css">body { background-color: #f0f0f0; font-family: 'Roboto', sans-serif; font-size: 16px; font-weight: 400; } h1 { font-weight: 700; }</code>
The above is the detailed content of How to set the background and font when creating an HTML project with vscode. For more information, please follow other related articles on the PHP Chinese website!