Overriding predefined styles in W3.CSS
W3.CSS is an easy-to-use small readymade CSS classes development framework environment in HTML website webpage. It provides web developers with built-in styles classes for multiple object elements such as readymade website component buttons, containers, font typography, and website layout structure. Many times, web developers override default W3.CSS styles to meet particular web design requirements. Where you can manually apply it to the webpage content using custom CSS as per your web development needs.

So let us effectively override the predefined styles classes in W3.CSS.
Using Custom CSS in W3.CSS.
To override W3.CSS styles in an existing HTML website webpage, you can manually create custom W3.CSS code for the webpage after adding the W3.CSS stylesheet link to the webpage. This way, your custom W3.CSS styles will override the built-in styles, and it will completely replace your old W3.CSS file.
W3.CSS button styles override example.
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Basic Overriding W3.CSS Styles Example</title>
<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”>
<style>
/* let create ustom w3.css ode to Override button style */
.w3-button {
background-color: blue; /* apply Custom blue background */
color: yellow; /* apply Custom white yellow color */
padding: 19px 34px; /* apply Custom button padding */
font-size: 20px; /* apply Custom button font text size */
border-radius: 20px; /* apply Custom button border radius pie */
}
/* add Custom button Hover Effect styles */
.w3-button:hover {
background-color: white; /* it displays Slightly darker white on hover */
cursor: pointer;
}
</style>
</head>
<body>
<h2><center>Let Tray Override Button Style</center></h2>
<center><button class=”w3-button”>Button with Custom Style</button></center>
</body>
</html>
W3.CSS button styles override explanation.
- W3.CSS custom CSS – Here you will see in the above W3.CSS source code example, the custom CSS code written will override the default w3-button class styles. Where W3.CSS changes the button background color, button padding, font size, and pie order of button border in the webpage.
- W3.CSS hover effect – This changes the button hover background color when a web visitor applies a hover effect to the access button using the :hover pseudo-class in the current webpage.
Overriding W3.CSS Specification.
Sometimes you need a more specific selector to manually ensure that your styles override the W3.CSS source code. For example, if you want to replace the styles of a webpage button only within a particular container in your webpage, you must manually apply a more specific CSS selector to the webpage.
Overriding styles within a specific container example.
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Specific w3.css class Override example</title>
<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”>
<style>
/* let tary Override some W3.CSS button styles in a particular container w3.css component */
.test-container .w3-button {
background-color: green; /* apply Custom green button background */
color: yellow; /* apply Custom yellow button text color */
}
</style>
</head>
<body>
<div class=”test-container”>
<center><button class=”w3-button”>Let create custom button in test container</button></center>
</div>
<br>
<div>
<center><button class=”w3-button w3-red”>This button Display Without any Speific Override Effect</button></center>
</div>
</body>
</html>
Overriding W3.CSS Specification explanation.
- W3.CSS specific selectors – Here you can use test-container .w3-button to target only existing webpage buttons inside the test-container class in the webpage, and these custom styles do not modify any buttons outside the test container.
- W3.CSS Scope of the override – By using multiple specific selectors in your existing webpage source code, you limit the styles override in the existing webpage to a specific portion of a particular page of your webpage, i.e. you can apply W3.CSS universal styling only where needed.
Overriding W3.CSS Flexbox and Grid Layouts.
You use Flexbox and Grid container components for W3.CSS page layout structure management in any of your webpages. But if you need user defined custom adjustments in the existing webpage. So, you can override these webpage layout styles using your own W3.CSS rules.
Override Flexbox Layout Example.
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Let Tray Flexbox Override In w3.css Example</title>
<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”>
<style>
/* let manual Override the W3.CSS flex layout components styles*/
.w3-row {
display: flex; /* create Flexbox layout */
justify-content: space-between; /* apply Adjust spacing between column items */
}
.w3-col {
flex: 1; /* it Make each column equal space in webpage */
padding: 10px; /* it add padding between column*/
margin: 10px; /* it Add margin around flex column */
}
</style>
</head>
<body>
<center><h2>Let Tray Sme Overriding Flexbox Layout</h2></center>
<div class=”w3-row”>
<div class=”w3-col”>
<div style=”background-color:red; height:100px;”>Flexbox Column 1</div>
</div>
<div class=”w3-col”>
<div style=”background-color:blue; height:100px;”>Flexbox Column 2</div>
</div>
<div class=”w3-col”>
<div style=”background-color:green; height:100px;”>Flexbox Column 3</div>
</div>
<div class=”w3-col”>
<div style=”background-color:yellow; height:100px;”>Flexbox Column 3</div>
</div>
</div>
</body>
</html>
Overriding W3.CSS Flexbox and Grid Layouts explanation.
- W3.CSS Flexbox Layout – You can override the .w3-row class to use display: flex and custom justify-content-space-between to control and manage the spacing between columns in your W3.CSS page layout structure.
- W3.CSS Flex Column Behaviour – You can manually adjust the .w3-col class with flex: 1 to apply equal width to all columns in your W3.CSS page layout structure.