CSS / 4 MIN READ
Black Label
Design sleek, modern black labels for various UI elements.
From the original Fervor library. Examples may use older package versions.
Black label
Step 1: Set up the HTML file Create an HTML file and set up the basic structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Realistic Black Label</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="black-label">Your Text Here</div>
</body>
</html>
Step 2: Create the CSS file Create a new CSS file (styles.css) in the same directory as the HTML file.
Step 3: Style the black label Open the CSS file (styles.css) and add the following code to style the black label:
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0; /* Change this to your desired background color */
}
.black-label {
display: inline-block;
padding: 10px 15px; /* Adjust padding as needed */
background-color: #000; /* Black background */
color: #fff; /* White text color */
font-size: 16px; /* Adjust font size as needed */
font-weight: bold; /* Adjust font weight as needed */
border-radius: 5px; /* Adjust border radius for rounded corners */
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); /* Add subtle shadow */
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); /* Add gradient effect */
background-size: 10px 10px; /* Adjust the size of the gradient pattern */
}
Step 4: Link the CSS file to the HTML In the head section of the HTML file, link the CSS file by adding the following line:
<link rel="stylesheet" href="styles.css">
Step 5: Customize the label
Now you can customize the label as per your needs. You can change the text inside the div element to display the desired content on the label. You can also adjust the CSS properties, such as padding, font size, font weight, and border radius, to match your design preferences.
For example, if you want to display “Important” as the label text and increase the font size, you can modify the HTML like this:
<body>
<div class="black-label">Important</div>
</body>
And in the CSS file, adjust the font size:
.black-label {
/* Other CSS properties */
font-size: 20px; /* Increase the font size */
/* Other CSS properties */
}
Step 6: Preview your black label Save the HTML and CSS files, then open the HTML file in your web browser to see the realistic black label you created!
That’s it! You’ve now created a realistic black label using HTML and CSS. You can further experiment with different CSS properties to enhance the label’s appearance, such as adding more gradients, changing colors, or adjusting the shadow intensity. Have fun customizing your black label!
Bonus Adding Grit
To add a bit of grit and wear to the black label, you can apply texture and distressed effects to the background. One way to achieve this is by using a subtle noise pattern for texture and applying distressed lines for a worn-out appearance. Here’s how you can do it:
Step 1: Add Noise Texture First, we’ll create a noise texture as a background image for the label. You can use an image editing tool like Photoshop or an online noise texture generator to create a small black-and-white noise pattern.
Save the noise pattern as “noise.png” in the same directory as your HTML and CSS files.
Step 2: Update CSS Now, we’ll update the CSS to apply the noise texture and distressed lines effect.
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0; /* Change this to your desired background color */
}
.black-label {
display: inline-block;
padding: 10px 15px; /* Adjust padding as needed */
background-color: #000; /* Black background */
color: #fff; /* White text color */
font-size: 16px; /* Adjust font size as needed */
font-weight: bold; /* Adjust font weight as needed */
border-radius: 5px; /* Adjust border radius for rounded corners */
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); /* Add subtle shadow */
/* Add noise texture */
background-image: url("noise.png");
background-size: 100% 100%;
background-blend-mode: overlay;
/* Add distressed lines */
position: relative;
overflow: hidden;
}
.black-label::before {
content: "";
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
border: 1px solid rgba(255, 255, 255, 0.2);
pointer-events: none;
}
Step 3: Adjust Distressed Lines
The ::before pseudo-element in the CSS code creates distressed lines around the label. You can further customize the distressed lines by adjusting the color, opacity, and thickness.
Step 4: Preview Save the changes and refresh your HTML page in the web browser to see the black label with grit and wear effects.
The combination of the noise texture and distressed lines should give the black label a more realistic and worn-out appearance. You can experiment with different noise patterns and distressed line styles to achieve the level of grit and wear you desire.