Attributes in HTML

What are attributes?

  1. Every HTML tag has some attribute associated with it, attributes define the specification of that tag.
    1. For example: If you are a human being, then your attributes/specifications are height, weight, age, color etc.
  2. An attribute is always written in the opening tag.
  3. An attribute is always written in name="value" pair.
  4. Attribute value always enclosed in double quotes or single quotes.

Body tag Attributes?

  1. We have already learned, How to create a basic HTML page.
  2. A basic HTML page contains at least head and body tags.
  3. Body tag has various attributes associated with it, we have discussed some of them here in this article.
    1. text: This attributes used to define the text color in the body means your HTML content written in the body tag.
    2. bgcolor: This attribute is used to define the background color of the body (Web page).
    3. background: This attribute is used to add any background images of your web page.

Example

Let's see an HTML page example to demonstrate how attributes work.

HTML Page with attributes.
  1. As shown in the above figure body tag is created with two attributes
    1. bgcolor = "red": which makes the red background of the body.
    2. text = "white": which makes body text of color white.
  2. The output of the above example is shown in the figure below.
The output of the above example.

Color Codes

  1. As you have seen in the above example, that we have used the color name like red and white for the color.
  2. But in computer science, there are other popular methods to provide the colors as listed below.
    1. Color by name
    2. HEX color codes
    3. RGB color codes

Color by name

  1. In this method, we simply write the color names like red, green, white.

Color by HEX codes

  1. The most popular are Hex color codes.
  2. It consists of six digits.
  3. It always starts with the #(hash)  symbol.
  4. Each pair of characters in the Hex code, representing the intensity of red, green and blue in the color respectively.
    1. Example: #XXXXXX
  5. Hex code pair values range from 00, which is the lowest intensity of a color, to FF which represents the highest intensity.

Example of Hex Color Codes

ColorHex Code
Black #000000
White #ffffff
Red #ff0000
Green #00ff00
Blue #0000ff

RGB color codes

  1. In RGB color can be written as given below.
    1. Example:  rgb(red, green, blue)
  2. Each parameter (red, green, and blue) defines the intensity of the color between 0 and 255.

Watch the video


Watch the video in Hindi




Comments

Popular posts from this blog

Program to calculate telephone bill

Overview of Go lang

Arrays in C Language

String in golang

Data Types in Go language

Say Hello world in Go lang

Installing go lang

Arrays in Go lang

Decision Making in Go lang

Creating your first html page