Difference between revisions of "Help:Wiki University Wikitext--Width and Height"

From FamilySearch Wiki
Jump to navigation Jump to search
m (add section: effect of borders on width)
m (m)
Line 45: Line 45:
 
Here is the coding:
 
Here is the coding:
 
<div style="border:2px solid crimson; background-color:moccasin; padding:10px; width:50%; font-size:10pt; font-family:Courier New"><nowiki><div style="</nowiki><font color="blue">width:</font color><font color="blue">400px; </font color><font color="blue">height:</font color><font color="blue">200px;</font color> border:1px solid red">Lorem ipsum ...<nowiki></div></nowiki></div>
 
<div style="border:2px solid crimson; background-color:moccasin; padding:10px; width:50%; font-size:10pt; font-family:Courier New"><nowiki><div style="</nowiki><font color="blue">width:</font color><font color="blue">400px; </font color><font color="blue">height:</font color><font color="blue">200px;</font color> border:1px solid red">Lorem ipsum ...<nowiki></div></nowiki></div>
 
==Effect of borders on width==
 
*When a border is added to an element such as a div tag, the area of the div tag if it is called out will remain.  If a container is 640 pixels wide and a 50 pixel border is added, the 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 affect the width of the entire element.  Here's a sample:
 
<div style="width:640px; height:50px; background-color:red"></div><br><br>
 
<div style="width:640px; height:50px; background-color:red; border:50px solid green"></div>
 
  
 
==Try these out==
 
==Try these out==

Revision as of 10:23, 17 April 2020

Lessons


Intermediate


Advanced


Flexbox


Additional Helps

Width[edit | edit source]

Height-width.png

Using either paragraph or div tags you are able to control the width on the page. If you wanted the text to only go part way across the page you could do it two different ways.

  • Set the width to a certain number of pixels.
  • Set the width as a percentage.

Here is the attribute coding:

width:400px (for pixels)
width:50% (in percentages)

Here is our lorem ipsum paragraph with these two attributes with a border to see the examples more clearly:

  • The width is set at 400 pixels
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet iaculis metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce elementum efficitur faucibus. Curabitur eleifend quis ligula ac ullamcorper. Curabitur eget suscipit turpis.


  • The width is set at 50%
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet iaculis metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce elementum efficitur faucibus. Curabitur eleifend quis ligula ac ullamcorper. Curabitur eget suscipit turpis.

Height[edit | edit source]

The height can be set with the attribute coding:

height:200px

  • NOTICE use pixels for the height coding, percentages will not work in height.

Here is our lorem ipsum with a height of 300 pixels:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet iaculis metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce elementum efficitur faucibus. Curabitur eleifend quis ligula ac ullamcorper. Curabitur eget suscipit turpis.
  • NOTICE that the container is much higher than necessary.
  • NOTICE that the text is at the top of the container.

Width and height used together[edit | edit source]

Here is lorem ipsum in a div tag with a width of 400 pixels and a height of 200 pixels:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet iaculis metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce elementum efficitur faucibus. Curabitur eleifend quis ligula ac ullamcorper. Curabitur eget suscipit turpis.

Here is the coding:

<div style="width:400px; height:200px; border:1px solid red">Lorem ipsum ...</div>

Try these out[edit | edit source]

Tests.gif
Exercises

In your sandbox put the lorem ipsum in a div tag container with your choice of border and a width of 200 pixels and a height of 400 pixels.


Quick Quiz
  • You can't use both width and height in a div tag
A. True
B. False
  • You can't use both width and height in a paragraph tag
A. True
B. False
  • You can use percentages in height attributes
A. True
B. False