CSS Form Styling ID

User
add this id – custom-registration-form

label{
width:100%;
display: block;
margin-bottom: 17px;
font-weight: 700;
font-size: 12.75px;
color: #000;
}
input[type=date], input[type=email], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=url], select, textarea {
width: 100%;
border: 1px solid #666;
border-radius: 3px;
padding: .5rem 1rem;
transition: all .3s;
width: 100%;
padding: 10px;
font-size: 15px;
border: 1px solid #fff;
border-radius: 6px;
box-sizing: border-box;
margin-top: 14px;
height: 60px;
}
[type=submit], [type=button] {

transition: all 0.3s;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 6px;
font-weight: bold;
font-size: 16px;
line-height: 1;
text-transform: uppercase;
float: right;
margin-top: 40px;
background: #000;
}
[type=submit]:hover, [type=submit]:focus, [type=button]:hover, [type=button]:focus {
color: #ffffff;
background-color: #000 !important;
text-decoration: none;
opacity: 0.9;
}
#response{
color: #fff !important;
font-weight: 500;
font-family: 'Montserrat';
}

into this css , so that it will impact only on this form id !

Assistant
To scope your CSS styles to only affect the form with the ID `custom-registration-form`, you need to prefix all selectors with `#custom-registration-form`. Here's your modified CSS:

#custom-registration-form label {
	width: 100%;
	display: block;
	margin-bottom: 17px;
	font-weight: 700;
	font-size: 12.75px;
	color: #000;
}

#custom-registration-form input[type="date"],
#custom-registration-form input[type="email"],
#custom-registration-form input[type="number"],
#custom-registration-form input[type="password"],
#custom-registration-form input[type="search"],
#custom-registration-form input[type="tel"],
#custom-registration-form input[type="text"],
#custom-registration-form input[type="url"],
#custom-registration-form select,
#custom-registration-form textarea {
	width: 100%;
	border: 1px solid #666;
	border-radius: 3px;
	padding: 0.5rem 1rem;
	transition: all 0.3s;
	font-size: 15px;
	border: 1px solid #fff;
	border-radius: 6px;
	box-sizing: border-box;
	margin-top: 14px;
	height: 60px;
}

#custom-registration-form [type="submit"],
#custom-registration-form [type="button"] {
	transition: all 0.3s;
	color: #fff;
	padding: 10px 20px;
	border: none;
	border-radius: 6px;
	font-weight: bold;
	font-size: 16px;
	line-height: 1;
	text-transform: uppercase;
	float: right;
	margin-top: 40px;
	background: #000;
}

#custom-registration-form [type="submit"]:hover,
#custom-registration-form [type="submit"]:focus,
#custom-registration-form [type="button"]:hover,
#custom-registration-form [type="button"]:focus {
	color: #ffffff;
	background-color: #000 !important;
	text-decoration: none;
	opacity: 0.9;
}

#custom-registration-form #response {
	color: #fff !important;
	font-weight: 500;
	font-family: 'Montserrat';
}

### ✅ Result
These styles will **only apply** to form fields, buttons, and labels inside the element with ID `custom-registration-form`, avoiding any global side effects.

Assistant
To ensure that the provided styles apply **only** to the form with ID `custom-registration-form`, you need to **scope** all selectors using `#custom-registration-form`. Here's the modified CSS:

#custom-registration-form label {
    width: 100%;
    display: block;
    margin-bottom: 17px;
    font-weight: 700;
    font-size: 12.75px;
    color: #000;
}

#custom-registration-form input[type="date"],
#custom-registration-form input[type="email"],
#custom-registration-form input[type="number"],
#custom-registration-form input[type="password"],
#custom-registration-form input[type="search"],
#custom-registration-form input[type="tel"],
#custom-registration-form input[type="text"],
#custom-registration-form input[type="url"],
#custom-registration-form select,
#custom-registration-form textarea {
    width: 100%;
    border: 1px solid #fff;
    border-radius: 6px;
    padding: 10px;
    font-size: 15px;
    box-sizing: border-box;
    margin-top: 14px;
    height: 60px;
    transition: all .3s;
}

#custom-registration-form [type="submit"],
#custom-registration-form [type="button"] {
    transition: all 0.3s;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    text-transform: uppercase;
    float: right;
    margin-top: 40px;
    background: #000;
}

#custom-registration-form [type="submit"]:hover,
#custom-registration-form [type="submit"]:focus,
#custom-registration-form [type="button"]:hover,
#custom-registration-form [type="button"]:focus {
    color: #ffffff;
    background-color: #000 !important;
    text-decoration: none;
    opacity: 0.9;
}

#custom-registration-form #response {
    color: #fff !important;
    font-weight: 500;
    font-family: 'Montserrat';
}

✅ **Effect:** These styles will now only apply to elements **inside the `#custom-registration-form`** and not affect any other form on the site.

Leave a Comment

Your email address will not be published. Required fields are marked *