Help:Wiki University HTML-- Borders
Lessons
- HOME
- Introduction
- Headers
- Lists
- Nesting Lists
- Comments
- Paragraphs
- Fonts - Changing
- Font Size
- Font Colors
- Font Bold-Italics
- Padding
- Margins
- Borders
- Width and Height
- Alignment
- Tables
- Tables - Borders
- Tables - Widths
- Tables - Captions
- Tables - Col Labels
- Tables - Cells
- Tables - Rows
- Tables - Placement
- Tables - Sorting
- Tables - Scrolling
- Tables - Col Only
- Tables - Col Spans
- Tables - Row Spans
- Infobox - Creating
- Infobox - Placing
- Infobox - If function
- Sidebars
- Navboxes
- Position - Relative
- Position - Absolute
- Misc
Flexbox/CSS Grid
Additional Helps
BORDERS[edit | edit source]
We have talked about backgrounds of paragraph and div tags and how the text inside those tags behaves. But instead of using background colors to show the space taken up by a paragraph, we can use borders.
- Here is our lorem ipsum paragraph with a border instead of a background:
- NOTICE the text has no space between the text and the border.
- NOTICE the border is spread all across the page.
Here is the attribute for the above border:
Lets break down this attribute:
- 1px - is the thickness of the line which is one pixel. You can have any size in pixels.
- Solid - is the type of line, that is, a solid line as opposed to a line that is dotted, dashed, etc.
- Red - is the color of the line using the names or HEX codes accepted by the Wiki.
So in the above example we have a solid red border that is one pixel thick.
BORDERS ON ONE, TWO, THREE SIDES[edit | edit source]
We can place borders on one two, three or on all four sides of the div tag just like padding and margins.
- To place a border on the bottom side, for example, we enter:
- NOTICE the red border is only on the bottom of the div tag container. This is useful if we want to separate paragraphs or other objects with a line.
KINDS OF BORDER LINES[edit | edit source]
For a complete list of accepted border types, click here
PADDING AND MARGINS IN BORDERS[edit | edit source]
Padding and margin attributes work the same way with borders.
- Padding will separate the text from the edge of the div or paragraph tag container.
- Margins will separate div and paragraph tags from each other.
BORDER RADIUS[edit | edit source]
The corners on boxes are square by default, but you can make them rounded by using this coding
This produces boxes with rounded corners which look like this:
- The radius of the corner is 5 pixels.
- You can limit the rounding of corners to certain ones which this coding:
border-radius-right-top:5px
border-radius-left-top:5px
border-radius-right-bottom:5px
border-radius-right-bottom:5px
BORDER SHADOW[edit | edit source]
Here is a nice effect for boxes, etc called box-shadows:
This is a nice effect. The box appears to stand above the page. Here is the coding:
- The first 10 pixels is the distance from the bottom edge of the box to the edge of the shadow.
- The second 10 pixels is the distance from the right edge of the box to the edge of the shadow.
- The 5 pixels is the distance the box is ABOVE the page. The greater the distance the fuzzier is the shadow. The closer the box is to the page the darker is the shadow.
- The #888888 is, of course, the HEX number for the color of the shadow, which is a dark gray in this example.
EFFECT OF BORDERS ON WIDTH OF ELEMENTS[edit | edit source]
- When a border is added to an element such as a div tag, the area of the div tag remains the same, however the whole element expands by the thickness of the border.
- For example, if a container is 640 pixels wide and a 50 pixel border is added, whole element will expand to 740 pixels and expand into the right sidebars. So if you are adding thick borders, you need to assess how it will effect the width of the entire element.
- In addition, the widened borders will push an another element out of the way by the thickness of the border that touches it:
TRY THESE OUT . . . . .[edit | edit source]
- Using a div tag put a border around our lorem ipsum paragraph of a "groove" type that is 10 pixels thick with whatever color you like.
- Using a div tag put a border around our lorem ipsum paragraph of a "ridge" type that is 15 pixels thick with whatever color you like.
- You can only put borders on all sides.
- A. True
- B. False
- There is a default space between text and borders
- A. True
- B. False
- Solid lines are all that is allowed in borders
- A. True
- B. False