HTML Colors and Fonts - SwatiMaurya08/html-notes GitHub Wiki
Colors are very important to give a good look and feel to your website. You can specify colors on page level using <body>
tag or you can set colors for individual tags using bgcolor attribute.
The <body>
tag has following attributes which can be used to set different colors β
-
bgcolor β sets a color for the background of the page.
-
text β sets a color for the body text.
-
alink β sets a color for active links or selected links.
-
link β sets a color for linked text.
-
vlink β sets a color for visited links β that is, for linked text that you have already clicked on.
There are following three different methods to set colors in your web page β
-
Color names β You can specify color names directly like green, blue or red.
-
Hex codes β A six-digit code representing the amount of red, green, and blue that makes up the color.
-
Color decimal or percentage values β This value is specified using the rgb( ) property.
Fonts play a very important role in making a website more user friendly and increasing content readability. Font face and color depends entirely on the computer and browser that is being used to view your page but you can use HTML <font>
tag to add style, size, and color to the text on your website. You can use a <basefont>
tag to set all of your text to the same size, face, and color.
The font tag is having three attributes called size, color, and face to customize your fonts. To change any of the font attributes at any time within your webpage, simply use the <font>
tag. The text that follows will remain changed until you close with the </font>
tag. You can change one or all of the font attributes within one <font>
tag.
Note βThe font and basefont tags are deprecated and it is supposed to be removed in a future version of HTML. So they should not be used rather, it's suggested to use CSS styles to manipulate your fonts. But still for learning purpose, this chapter will explain font and basefont tags in detail.
You can set content font size using size attribute. The range of accepted values is from 1(smallest) to 7(largest). The default size of a font is 3.
You can specify how many sizes larger or how many sizes smaller than the preset font size should be. You can specify it like <font size = "+n"> or <font size = "βn">
You can set font face using face attribute but be aware that if the user viewing the page doesn't have the font installed, they will not be able to see it. Instead user will see the default font face applicable to the user's computer.
You can set any font color you like using color attribute. You can specify the color that you want by either the color name or hexadecimal code for that color.
The <basefont>
element is supposed to set a default font size, color, and typeface for any parts of the document that are not otherwise contained within a <font>
tag. You can use the <font>
elements to override the <basefont>
settings.
The <basefont>
tag also takes color, size and face attributes and it will support relative font setting by giving size a value of +1 for a size larger or β2 for two sizes smaller.
The HTML
tag is used to create an HTML form and it has following syntax β<form action = "Script URL" method = "GET|POST">
form elements like input, textarea etc.
</form>
There are different types of form controls that you can use to collect data using HTML form β
- Text Input Controls
- Checkboxes Controls
- Radio Box Controls
- Select Box Controls
- File Select boxes
- Hidden Controls
- Clickable Buttons
- Submit and Reset Button
There are three types of text input used on forms β
-
Single-line text input controls β This control is used for items that require only one line of user input, such as search boxes or names. They are created using HTML
<input>
tag. -
Password input controls β This is also a single-line text input but it masks the character as soon as a user enters it. They are also created using HTMl
<input>
tag. -
Multi-line text input controls β This is used when the user is required to give details that may be longer than a single sentence. Multi-line input controls are created using HTML
<textarea>
tag.
This control is used for items that require only one line of user input, such as search boxes or names. They are created using HTML <input>
tag.
This is also a single-line text input but it masks the character as soon as a user enters it. They are also created using HTML <input>
tag but type attribute is set to password.
This is used when the user is required to give details that may be longer than a single sentence. Multi-line input controls are created using HTML <textarea>
tag.
Checkboxes are used when more than one option is required to be selected. They are also created using HTML <input>
tag but type attribute is set to checkbox..
Radio buttons are used when out of many options, just one option is required to be selected. They are also created using HTML <input>
tag but type attribute is set to radio.
A select box, also called drop down box which provides option to list down various options in the form of drop down list, from where a user can select one or more options.
If you want to allow a user to upload a file to your web site, you will need to use a file upload box, also known as a file select box. This is also created using the <input>
element but type attribute is set to file.
There are various ways in HTML to create clickable buttons. You can also create a clickable button using <input>
tag by setting its type attribute to button.
- submit - This creates a button that automatically submits a form.
- reset - This creates a button that automatically resets form controls to their initial values.
- button - This creates a button that is used to trigger a client-side script when the user clicks that button.
- image - This creates a clickable button but we can use an image as background of the button.
Hidden Form Controls
Hidden form controls are used to hide data inside the page which later on can be pushed to the server. This control hides inside the code and does not appear on the actual page. For example, following hidden form is being used to keep current page number. When a user will click next page then the value of hidden control will be sent to the web server and there it will decide which page will be displayed next based on the passed current page.
The <input type="hidden">
defines a hidden input field.
A hidden field let web developers include data that cannot be seen or modified by users when a form is submitted.
A hidden field often stores what database record that needs to be updated when the form is submitted.