×

CSS Form

You can create attractive HTML form by using CSS.

Style input Fields

The Input Field width properties are used to determine the width of the input field. Let us see an example of CSS style input fields:
<!DOCTYPE html>  
<html>  
<head>  
<style>   
input {  
    width: 100%;  
}  
</style>  
</head>  
<body>  
<p>A full-width input field:</p>  
<form>  
  <label for="fname">Address</label>  
  <input type="text" id="fname" name="fname" placeholder="Enter your addresss...">  
</form>  
</body>  
</html>
Try Now

Note: If you want to style a specific input type then use attribute selectors.

  • input[type=text] : You can only select text fields.
  • input[type=password] : You can only select password fields.
  • input[type=number] : You can only select number fields etc.

Padded inputs

This padding property is used to add space inside the text fields. The given below example of padded inputs. Example
input[type=text] {  
    width: 100%;  
    padding: 12px 20px;  
    margin: 8px 0;  
    box-sizing: border-box;  
}

Bordered inputs

This bordered property is used to change the border size and color. Only you can use border property. Example
input[type=text] {  
    border: 2px solid blue;  
    border-radius: 6px;  
}

Colored inputs

Colored inputs are used to set the background color buy using its properties ackground-color. Example
input[type=text] {  
    border: 2px solid blue;  
    border-radius: 6px;  
}

Input with icon/image

You can use icons/image inside the input by using background-image and background-positionproperty. Colored inputs are used to set the background color buy using its properties background-color. Example
<!DOCTYPE html>  
<html>  
<head>  
<style>   
input[type=text] {  
    width: 100%;  
    box-sizing: border-box;  
    border: 2px solid red;  
    border-radius: 4px;  
    font-size: 16px;  
    background-color:white;  
    background-image: url('images/search-icon.PNG');  
    background-position: 10px 10px;   
    background-repeat: no-repeat;  
    padding: 12px 20px 12px 40px;  
</style>  
</head>  
<body>  
<p>icon is used inside input</p>  
<form>  
  <input type="text" name="search" placeholder="Search..">  
</form>  
</body>  
</html>
Try Now

Related Topics

CSS Page-break-after Attribute

Page-break-after Attribute As its name implies, the page-break-before property is applied to include page break after any element, at the time of printing a document. It adds the page break after...

5 minutes read.

CSS Align

CSS Center Align Elements CSS center align is used to create align by using block element. You should specify margin: auto;properties. The element will take up the specified width and the remaining space....

2 minutes read.

Radial-gradient() CSS function

Radial-gradient() CSS function It defines a CSS in-built function, which produces a smooth transition among multiple colors. It is used to set any radial-gradient that is same as a background-image. This...

4 minutes read.

CSS Dropdowns

Dropdowns are one of the maximum crucial parts of an interactive internet site. CSS is a kind used to design the drop-down menus. A drop-down essentially is a group of...

5 minutes read.

Css Text Orientation

Introduction: The text-orientation property of CSS is used to specify the orientation of the text characters in the line of content. This property applies only with the vertical writing-mode and not...

4 minutes read.

CSS Word Wrap

Word Wrap in CSS: The word-wrap property in CSS is referred to break any lengthy word and wrap towards the next or following line. It is employed for preventing overflow...

1 minute read.

CSS Clip

CSS Clip The Clip property in CSS describes the element’s visible area. It applies over the elements which are absolutely positioned (position: absolute ;). Generally, it is used when an image...

2 minutes read.

CSS Background Color

It is one of the CSS properties to apply styling to html elements.This property is used to apply the background color to any HTML element.The background of an element includes...

2 minutes read.

CSS Opacity

The CSS Opacity property is used to set the clarity of the image. It is defined as degree and specify the transparency of an element. Note: Opacity value will be less...

1 minute read.

How to center a table in CSS

The table is used to store and arrange the data in tabular format. The data here can be of any form like text, image, links, etc. The table is made...

3 minutes read.

CSS Overlay

CSS Overlay: It measures to cover-up something’s surface along with a coating. CSS overlay sets anything over the top area of other things. It creates a web-page more attractive. The...

8 minutes read.

CSS Vertical Align

Vertical Align The vertical align CSS property describes the cell box of the table and an inline alignment vertically. This property is a self-explanatory and an essential property in CSS. But,...

2 minutes read.

How to change font size in CSS

How to change font size in CSS? Font Size: - Users may attract attention to content on a website page in various ways. One element in a sentence can be highlighted. You...

5 minutes read.

CSS Word-spacing

Word-spacing The work-spacing property of CSS is applied to manage the space among the words. We can decrease or increase the space among the words by the use of this property. It...

3 minutes read.

CSS Float

CSS Float: The float property of CSS is the positioning property. This property is applied to elements to push them either to left or right. It permits for wrapping facility...

4 minutes read.

CSS Filter

CSS Filter CSS filter is used to apply visual effects on the images, text, and other factors of the webpage. This filter property in CSS allows us to admit the effects like...

7 minutes read.

CSS Page-break-inside Attribute

Page-break-inside Attribute As its name implies, the page-break-before property is applied to include page break inside any element, at the time of printing any document. It adds the page break before...

3 minutes read.

CSS Navigation bar

CSS Navigation bar: A navigation system or navigation bar comes upon GUI that can help many visitors to access the information. A Navigation bar is a UI component on the...

11 minutes read.

Combine Background Image with Gradient Overlay

With the help of CSS gradient, we can display smooth and straightforward transitions between two or more colours. We can add the background images by combining the gradient property with...

2 minutes read.

CSS Arrow

CSS Arrow The arrow of CSS is applied to insert an array with the tooltip. It can make a tooltip as any speech bubble. Also, this arrow can be illustrated in...

4 minutes read.