Element Dimension

CSS plays so many role in how a screen width is suppose to display on any Media Screen. Using the Media Attribute in your HTML code, you can designate what media type can a style sheet be applied to. In addition to positioning elements, CSS rules can specify the actual dimensions of each page element.


<xml version = "1.0" ?>
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<-- setting dimension box and text alignment -->

<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> Simple Box Dimension</title>
<style type="text/css">

div { background-color: #ffccff;
       margin-bottom: .5em }
</style>
</head>

<body>

<div style="width: 20%">Here is some text that goes
in a box which is set to stretch across twenty percent of
the width of the screen.</div>


<div style="width: 80%; text-align: center">
Here is some CENTERED text that goes in a box
which is set to stretch across eighty percent of
the width of the screen.</div>


<div style="width: 20%; height: 30%; overflow: scroll">
This box is only twenty percent of the width and thirty percent
of the height. what do we do if it overflows? Set the overflow
property to scroll!</div>

</body>
</html>

The inline style in the First div, illustrates how to set the width of an element on screen; here, we indicate that the DIV should occupy 20% of the screen width. Most elements are left-aligned by default; however, this alignment can be altered to position the element elsewhere. The height of an element can be set similarly, using the height property. The height and width values also can be specified as relative or absolute lengths. For Example
width : 10em
Sets the element’s width to be equal to 10 times the font size. The Second div sets text in the element to be center aligned; other values for the text-aligned property include left and right.
One problem with setting both dimensions of an element is that the content inside the element can exceed the set boundaries, in which case the element is simply made large enough for all the content to fit. However, in the Third div, we set the overflow property to scroll, a setting that adds scrollbars if the text overflows the boundaries.
Source → Deitel – 3rd Edition

0

About Charming Prince

Being a Web Developer/Web Author, i had an idea to disseminate my knowledge in the field of web development to other people by opening this online free tutorials on programming languages, in so doing, to share ideas where applicable...As well as to share ideas in related area pertaining to information dissemination and media such as Movies, Music , and Games. as per these are the areas which i like the most and i think most people do like this area as well, so I'll try to make my explanation short but concise...
This entry was posted in Programming, Tutorial and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar