HTML - Backgrounds: Note
HTML - Backgrounds: Note
   Note −          The bgcolor attribute
   deprecated in HTML5. Do not use
   this attribute.
Following is the syntax to use bgcolor
attribute with any HTML tag.
<tagname bgcolor =
"color_value"...>
This color_value can be given in any of the
following formats −
<!-- Format 1 - Use color name --
>
<table bgcolor = "lime" >
Example
<!DOCTYPE html>
<html>
  <head>
      <title>HTML Background
Colors</title>
   </head>
  <body>
      <!-- Format 1 - Use color
name -->
      <table bgcolor = "yellow"
width = "100%">
         <tr>
           <td>
                 This background is
yellow
           </td>
         </tr>
     </table>
</html>
This will produce the following result −
Object 1
   Note −         The background attribute
   deprecated in HTML5. Do not use
   this attribute.
Following is the syntax to use background
attribute with any HTML tag.
   Note − The background attribute is
   deprecated and it is recommended to
   use Style Sheet for background
   setting.
<tagname background = "Image
URL"...>
The most frequently used image formats are
JPEG, GIF and PNG images.
Example
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Background
Images</title>
   </head>
   <body>
        <!-- Set table background
-->
      <table background =
"/images/html.gif" width = "100%"
height = "100">
         <tr><td>
            This background is
filled up with HTML image.
         </td></tr>
        </table>
    </body>
</html>
This will produce the following result −
                        Object 2
Patterned & Transparent Backgrounds
<!DOCTYPE html>
<html>
    <head>
      <title>HTML Background
Images</title>
   </head>
  <body>
      <!-- Set a table background
using pattern -->
      <table background =
"/images/pattern1.gif" width =
"100%" height = "100">
         <tr>
           <td>
               This background is
filled up with a pattern image.
            </td>
        </tr>
     </table>
</html>
This will produce the following result −
                        Object 3
               HTML – Colors
  Ye                Fu
        Li    Aq
  llo               chs
        me    ua
  w                 ia
        Gr          Pu
  Re          Bl
        ee          rpl
  d           ue
        n           e
  M
        Ol    Na    Te
  aro
        ive   vy    al
  on
Example
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Colors by
Name</title>
   </head>
</html>
HTML Colors - Hex Codes
        #000
 
        000
        #FF0
 
        000
        #00F
 
        F00
        #000
 
        0FF
        #FFF
 
        F00
        #00F
      FFF
      #FF0
 
      0FF
      #C0
      C0C
      0
      #FFF
 
      FFF
Example
<!DOCTYPE html>
<html>
    <head>
      <title>HTML Colors by
Hex</title>
   </head>
            rgb(0,0,
 
            0)
            rgb(255
 
            ,0,0)
    rgb(0,2
 
    55,0)
    rgb(0,0,
 
    255)
    rgb(255
 
    ,255,0)
    rgb(0,2
 
    55,255)
    rgb(255
 
    ,0,255)
    rgb(192
    ,192,19
    2)
    rgb(255
    ,255,25
    5)
Example
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Colors by RGB
code</title>
   </head>
      <table bgcolor =
"rgb(0,0,0)">
           <tr>
               <td>
               <font color =
"rgb(255,255,255)">This text will
appear white on black
background.</font>
            </td>
           </tr>
       </table>
   </body>
</html>
Browser Safe Colors
                    003
003 003 003 003           003
                    3C
300 333 366 399           3FF
                    C
                    006
006 006 006 006           006
                    6C
600 633 666 699           6FF
                    C
                    009
009 009 009 009           009
                    9C
900 933 966 999           9FF
                    C
00   00   00   00   00C 00C
CC CC CC CC CC CF
00   33   66   99   C     F
                    330
330 330 330 330           330
                    0C
000 033 066 099           0FF
                    C
                    333
333 333 333 333           333
                    3C
300 333 366 399           3FF
                    C
                    336
336 336 336 336           336
                    6C
600 633 666 699           6FF
                    C
                    339
339 339 339 339           339
                    9C
900 933 966 999           9FF
                    C
33   33   33   33   33C 33C
CC CC CC CC CC CF
00   33   66   99   C     F
                    33F
33F 33F 33F 33F           33F
                    FC
F00 F33 F66 F99           FFF
                    C
                    660
660 660 660 660           660
                    0C
000 033 066 099           0FF
                    C
                    663
663 663 663 663           663
                    3C
300 333 366 399           3FF
                    C
                    666
666 666 666 666           666
                    6C
600 633 666 699           6FF
                    C
                    669
669 669 669 669           669
                    9C
900 933 966 999           9FF
                    C
66   66   66   66   66C 66C
CC CC CC CC CC CF
00   33   66   99   C     F
                    66F
66F 66F 66F 66F           66F
                    FC
F00 F33 F66 F99           FFF
                    C
                    990
990 990 990 990           990
                    0C
000 033 066 099           0FF
                    C
                    993
993 993 993 993           993
                    3C
300 333 366 399           3FF
                    C
                    996
996 996 996 996           996
                    6C
600 633 666 699           6FF
                    C
                    999
999 999 999 999           999
                    9C
900 933 966 999           9FF
                    C
99   99   99   99   99C 99C
CC CC CC CC CC CF
00   33   66   99   C     F
                    99F
99F 99F 99F 99F           99F
                    FC
F00 F33 F66 F99           FFF
                    C
CC CC CC CC CC CC
000 003 006 009 00C 00F
0    3    6    9    C     F
CC CC CC CC CC CC
330 333 336 339 33C 33F
0    3    6    9    C     F
CC CC CC CC CC CC
660 663 666 669 66C 66F
0    3    6    9    C     F
CC CC CC CC CC CC
990 993 996 999 99C 99F
0    3    6    9    C   F
CC CC CC CC CC CC
CC CC CC CC CC CC
00   33   66   99   CC FF
CC CC CC CC CC CC
FF FF FF FF FF          FFF
00   33   66   99   CC F
FF FF FF FF FF0
                        FF0
000 003 006 009 0C
                        0FF
0    3    6    9    C
FF FF FF FF FF3
                        FF3
330 333 336 339 3C
                        3FF
0    3    6    9    C
FF FF FF FF FF6
                        FF6
660 663 666 669 6C
                        6FF
0    3    6    9    C
FF FF FF FF FF9
                        FF9
990 993 996 999 9C
                        9FF
0    3    6    9    C
FF FF FF FF FF          FF
CC CC CC CC CC CC
00   33   66   99   CC FF
FF FF FF FF FFF
                        FFF
FF FF FF FF FC
                        FFF
00   33   66   99   C
HTML – Fonts
    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.
Set Font Size
<!DOCTYPE html>
<html>
    <head>
      <title>Setting Font
Size</title>
   </head>
    <body>
      <font size = "1">Font size
= "1"</font><br />
        <font size =               "2">Font size
=   "2"</font><br />
        <font size =               "3">Font size
=   "3"</font><br />
        <font size =               "4">Font size
=   "4"</font><br />
        <font size =               "5">Font size
=   "5"</font><br />
        <font size =               "6">Font size
=   "6"</font><br />
        <font size =               "7">Font size
=   "7"</font>
     </body>
</html>
This will produce the following result −
                        Object 4
Relative Font Size
<!DOCTYPE html>
<html>
    <head>
      <title>Relative Font
Size</title>
   </head>
    <body>
      <font size = "-1">Font size
= "-1"</font><br />
        <font size         = "+1">Font     size
=   "+1"</font><br         />
        <font size         = "+2">Font     size
=   "+2"</font><br         />
        <font size         = "+3">Font     size
=   "+3"</font><br         />
        <font size         = "+4">Font     size
=   "+4"</font>
     </body>
</html>
This will produce the following result −
Object 5
<!DOCTYPE html>
<html>
    <head>
        <title>Font Face</title>
    </head>
    <body>
      <font face = "Times New
Roman" size = "5">Times New
Roman</font><br />
      <font face = "Verdana" size
= "5">Verdana</font><br />
      <font face = "Comic sans
MS" size =" 5">Comic Sans
MS</font><br />
      <font face = "WildWest"
size = "5">WildWest</font><br />
      <font face = "Bedrock" size
= "5">Bedrock</font><br />
   </body>
</html>
This will produce the following result −
Object 6
<!DOCTYPE html>
<html>
    <head>
      <title>Setting Font
Color</title>
   </head>
    <body>
      <font color =
"#FF00FF">This text is in
pink</font><br />
      <font color = "red">This
text is red</font>
   </body>
</html>
This will produce the following result −
The <basefont> Element
<!DOCTYPE html>
<html>
    <head>
      <title>Setting Basefont
Color</title>
   </head>
  <body>
      <basefont face = "arial,
verdana, sans-serif" size = "2"
color = "#ff0000">
      <p>This is the page's
default font.</p>
      <h2>Example of the
<basefont> Element</h2>
</html>
This will produce the following result −
Object 8
HTML – Forms
Form Attributes
action
method
3 target
enctype
4 application/x-www-form-urlencoded −
   This is the standard method most forms
   use in simple scenarios.
  <head>
      <title>Text Input
Control</title>
   </head>
  <body>
     <form >
         First name: <input type
= "text" name = "first_name" />
         <br>
         Last name: <input type =
"text" name = "last_name" />
      </form>
  </body>
</html>
This will produce the following result −
Object 7
Attributes
type
2 name
value
size
maxlength
<!DOCTYPE html>
<html>
    <head>
      <title>Password Input
Control</title>
   </head>
    <body>
       <form >
         User ID : <input type =
"text" name = "user_id" />
             <br>
         Password: <input type =
"password" name = "password" />
      </form>
     </body>
</html>
This will produce the following result −
Object 9
Attributes
1 type
    Indicates the type of input control and for
    password input control it will be set
    to password.
name
value
size
<!DOCTYPE html>
<html>
    <head>
      <title>Multiple-Line Input
Control</title>
   </head>
    <body>
        <form>
            Description : <br />
         <textarea rows = "5"
cols = "50" name = "description">
            Enter description
here...
         </textarea>
        </form>
    </body>
</html>
This will produce the following result −
                        Object 10
Attributes
name
rows
3 cols
   Indicates the number of columns of text
   area box
Checkbox Control
<!DOCTYPE html>
<html>
    <head>
      <title>Checkbox
Control</title>
   </head>
     <body>
        <form>
         <input type = "checkbox"
name = "maths" value = "on">
Maths
         <input type = "checkbox"
name = "physics" value = "on">
Physics
      </form>
     </body>
</html>
This will produce the following result −
Attributes
type
name
value
4 checked
   Set to checked if you want to select it by
   default.
<!DOCTYPE html>
<html>
    <head>
      <title>Radio Box
Control</title>
   </head>
    <body>
        <form>
         <input type = "radio"
name = "subject" value = "maths">
Maths
         <input type = "radio"
name = "subject" value =
"physics"> Physics
      </form>
    </body>
</html>
This will produce the following result −
                        Object 12
Attributes
type
name
checked
    <body>
        <form>
         <select name =
"dropdown">
            <option value =
"Maths" selected>Maths</option>
            <option value =
"Physics">Physics</option>
         </select>
        </form>
    </body>
</html>
This will produce the following result −
Attributes
name
size
3 multiple
     If set to "multiple" then allows a user to
     select multiple items from the menu.
value
selected
<!DOCTYPE html>
<html>
    <head>
      <title>File Upload
Box</title>
   </head>
    <body>
        <form>
         <input type = "file"
name = "fileupload" accept =
"image/*" />
      </form>
    </body>
</html>
This will produce the following result −
Object 14
Attributes
name
accept
Button Controls
submit
reset
3 button
image
Example
<!DOCTYPE html>
<html>
    <head>
      <title>File Upload
Box</title>
   </head>
    <body>
        <form>
         <input type = "submit"
name = "submit" value = "Submit"
/>
         <input type = "reset"
name = "reset" value = "Reset"
/>
         <input type = "button"
name = "ok" value = "OK" />
         <input type = "image"
name = "imagebutton" src =
"/html/images/logo.png" />
      </form>
    </body>
</html>
This will produce the following result −
Hidden Form Controls
    <head>
      <title>File Upload
Box</title>
   </head>
    <body>
        <form>
            <p>This is page 10</p>
         <input type = "hidden"
name = "pagename" value = "10" />
         <input type = "submit"
name = "submit" value = "Submit"
/>
         <input type = "reset"
name = "reset" value = "Reset"
/>
      </form>
    </body>
</html>
This will produce the following result −
Object 16