The letter-spacing
property in CSS is used to adjust the space between characters in a text element. This can be particularly useful for enhancing readability or achieving a specific design effect.
The letter-spacing
property can be set using various units such as pixels (px), ems (em), or percentages (%). Here’s a simple example:
p {
letter-spacing: 2px;
}
p {
letter-spacing: 0.1em;
}
Although less common, you can use percentages to set letter-spacing.
p {
letter-spacing: 10%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CoderSmile Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Welcome to CoderSmile</h1>
<h2>Getting Started</h2>
<p>This guide will help you set up your development environment quickly and easily. Follow the steps below to get started.</p>
<p>Whether you are a beginner or an experienced developer, having the right tools is crucial for efficient coding.</p>
</body>
</html>
<style>
/* styles.css */
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
font-size: 32px;
line-height: 1.3;
letter-spacing: 1px; /* Adding letter-spacing */
}
h2 {
font-size: 24px;
line-height: 1.4;
letter-spacing: 0.5px; /* Adding letter-spacing */
}
p {
font-size: 16px;
line-height: 1.6;
letter-spacing: 0.05em; /* Adding letter-spacing */
}
</style>