Showing posts with label table text alignment. Show all posts
Showing posts with label table text alignment. Show all posts

Thursday 5 December 2013

CSS : COLLAPSE BORDERS

CSS : TABLE WIDTH and HEIGHT

CSS : TABLE PADDING

CSS : TABLE TEXT ALIGNMENT


Table Text Alignment

The text in a table is aligned with the text-align and vertical-align properties.
The text-align property sets the horizontal alignment, like left, right, or center:

Example

td
{
text-align:right;
}

The vertical-align property sets the vertical alignment, like top, bottom, or middle:

Example

td
{
height:50px;
vertical-align:bottom;
}

CSS : TABLE COLOR

CSS : BOX MODEL


The CSS Box Model

All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.
The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.
The box model allows us to place a border around elements and space elements in relation to other elements.
The image below illustrates the box model:

Explanation of the different parts:
  • Margin - Clears an area around the border. The margin does not have a background color, it is completely transparent
  • Border - A border that goes around the padding and content. The border is affected by the background color of the box
  • Padding - Clears an area around the content. The padding is affected by the background color of the box
  • Content - The content of the box, where text and images appear
In order to set the width and height of an element correctly in all browsers, you need to know how the box model works.

Width and Height of an Element

* Important: When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add the padding, borders and margins.
The total width of the element in the example below is 300px:
width:250px;
padding:10px;
border:5px solid gray;
margin:10px;
Let's do the math:
250px (width)
+ 20px (left and right padding)
+ 10px (left and right border)
+ 20px (left and right margin)
= 300px
Assume that you had only 250px of space. Let's make an element with a total width of 250px:


Example

width:220px;
padding:10px;
border:5px solid gray;
margin:0px;

The total width of an element should be calculated like this:
Total element width = width + left padding + right padding + left border + right border + left margin + right margin
The total height of an element should be calculated like this:

Total element height = height + top padding + bottom padding + top border + bottom border + top margin + bottom margin

Browsers Compatibility Issue

The example above does not display properly in IE8 and earlier versions.
IE8 and earlier versions includes padding and border in the width, if a DOCTYPE is NOT declared.
To fix this problem, just add a DOCTYPE to the HTML page:


Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
div.ex
{
width:220px;
padding:10px;
border:5px solid gray;
margin:0px;
}
</style>
</head>


CSS : BORDER PROPERTIES


Border Properties

The CSS border properties allow you to specify the style and color of an element's border.

Border Style

The border-style property specifies what kind of border to display.
*None of the border properties will have ANY effect unless the border-style property is set!


Border Width

The border-width property is used to set the width of the border.
The width is set in pixels, or by using one of the three pre-defined values: thin, medium, or thick.
Note: The "border-width" property does not work if it is used alone. Use the "border-style" property to set the borders first.

Example

p.one
{
border-style:solid;
border-width:5px;
}
p.two
{
border-style:solid;
border-width:medium;
}


Border Color

The border-color property is used to set the color of the border. The color can be set by:
  • name - specify a color name, like "red"
  • RGB - specify a RGB value, like "rgb(255,0,0)"
  • Hex - specify a hex value, like "#ff0000"
You can also set the border color to "transparent".
Note: The "border-color" property does not work if it is used alone. Use the "border-style" property to set the borders first.

Example

p.one
{
border-style:solid;
border-color:red;
}
p.two
{
border-style:solid;
border-color:#98bf21;
}

Border - Individual sides

In CSS it is possible to specify different borders for different sides:

Example

p
{
border-top-style:dotted;
border-right-style:solid;
border-bottom-style:dotted;
border-left-style:solid;
}

The example above can also be set with a single property:

Example

border-style:dotted solid;

The border-style property can have from one to four values.
  • border-style:dotted solid double dashed;
    • top border is dotted
    • right border is solid
    • bottom border is double
    • left border is dashed

  • border-style:dotted solid double;
    • top border is dotted
    • right and left borders are solid
    • bottom border is double

  • border-style:dotted solid;
    • top and bottom borders are dotted
    • right and left borders are solid

  • border-style:dotted;
    • all four borders are dotted
The border-style property is used in the example above. However, it also works with border-width and border-color.

Border - Shorthand property

As you can see from the examples above, there are many properties to consider when dealing with borders.
To shorten the code, it is also possible to specify all the individual border properties in one property. This is called a shorthand property.
The border property is a shorthand for the following individual border properties:
  • border-width
  • border-style (required)
  • border-color

Example

border:5px solid red;


All CSS Border Properties

Property
Description
border
Sets all the border properties in one declaration
border-bottom
Sets all the bottom border properties in one declaration
border-bottom-color
Sets the color of the bottom border
border-bottom-style
Sets the style of the bottom border
border-bottom-width
Sets the width of the bottom border
border-color
Sets the color of the four borders
border-left
Sets all the left border properties in one declaration
border-left-color
Sets the color of the left border
border-left-style
Sets the style of the left border
border-left-width
Sets the width of the left border
border-right
Sets all the right border properties in one declaration
border-right-color
Sets the color of the right border
border-right-style
Sets the style of the right border
border-right-width
Sets the width of the right border
border-style
Sets the style of the four borders
border-top
Sets all the top border properties in one declaration
border-top-color
Sets the color of the top border
border-top-style
Sets the style of the top border
border-top-width
Sets the width of the top border
border-width
Sets the width of the four borders

Physics basic inventions and inventors

1.Which instrument is used to measure altitudes in aircraft's ? Audiometer Ammeter Altimeter Anemometer Explanation : ...