Position

Border, width, height, z-index, position (absolute only), top, bottom, left, right, and for background see Images. Complete Borders assignment with this new knowledge.

Vanguard of the property parade

Now that you know a few HTML element types, it’s time to start styling them. We have a lot of properties to go through, and for many I will just give the property type and a list of possible values. But here is our adopted property index. Get comfortable with it. A bit confusing at first, but once you’ve consulted it a few times, you’ll know it’s invaluable. The link includes all properties in an overwhelming list. But note the affinity sets near the top, starting with Fonts, Text, and ending with Extensions (which we’ll ignore, by the way). I will often link to subpages within this most appreciated resource.

Ready? Don’t be nervous; I strongly suggest you play with all new properties immediately in a dummy web page. You know how. Here we go…

How to position an element in the window

div.species { position: absolute;
              left: 15%;
              bottom: 0;
              }

Absolute is the only value I’m revealing for the position property at this point. This link won’t work for long, but Will used position for his ❝Hello World!❞: the HTML, the CSS. The other properties here will only work if you explicitly declare the position. So that first declaration is critical here. In general practice, you will use left or right for your x-axis, and top or bottom for your y-axis. Those are properties, and the values are just whatever units of measure you specify. New properties in summary:

  1. position: we will use only absolute for now; without this property, those below will do nothing at all
  2. top: distance from top boundary of browser window
  3. bottom
  4. left
  5. right

Oh, what was that?: ❝What happens if I position one element on top of another?❞ Then you’re dealing with the 3rd dimension, the z-axis. Something has to be on top. By default, the lower in the code an element is, the higher it will be in the z-axis. However, as with almost everything, you can override this.

div.genus   { z-index: 12; }
div.family  { z-index: 6; }

The z-index property accepts any non-negative integer. It’s all relative. You can use however big a value you want. In this example, the “genus” div will overlap, or be on top of, the “family” div, because 12 is bigger than 6. I believe the default for all elements is 1, but it could be 0. If two elements have the same z-index value, then the one later in the code will be on top.

How to size an element

div.order   { width: 80%; height: 48px; }

We are now in the realm of the box model, but we’re only partially covering it here. If you specify a smaller dimension than is needed, that is, if the content of the element in question doesn’t fit in the space you’ve given it, the element will become bigger than you want, as it grows to fit the content. These properties only affect block elements.

How to assign borders to an element

div.class   { border: 1px solid #f00; }

This is the simplest way to specify a border. It’s actually a shorthand property, meant to save you time. As a shorthand property, border takes multiple values in one declaration. They are separated by spaces. Breaking this down into its components, you could get the exact same results with:

div.phylum  { border-width: 1px;
              border-style: solid;
              border-color: #f00;
              }

You can also specify different borders for different edges of an element. You can use shorthand for this:

div.kingdom { border-right: 4px dotted gray; }

The four edges you can append to border- are top, right, bottom, and left. Here is the long version, which just gets unwieldy:

div.domain  { border-right-width: 2px;
              border-right-style: dotted;
              border-right-color: gray;
              }

But, yuck. By the way, border-bottom is a common way to make customizable underlines in CSS. Later on you will find out how to change the default, ugly underline for links and replace with your own special border-based underline.

Border-weight and border-color are straightforward. Following are the possible values for border-style. It all comes from our property index.

  1. solid
  2. dotted
  3. dashed
  4. groove
  5. ridge
  6. inset
  7. outset
  8. double
  9. none

No, you absolutely do not have to memorize those values for any quiz!

Summary of new properties

  1. position
  2. top, right, bottom, left: only work when paired with position
  3. width, height: only work with block elements
  4. border
  5. background: is next
 

4,624 Responses to “Position”

  1. oakley kleding nederland

    Hello this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding know-how so I wanted to get guidance from someone with experience. Any help wou…

  2. toms blu and orange 4s

    Wonderful blog you have here but I was wanting to know if you knew of any forums that cover the same topics discussed here? I’d really like to be a part of community where I can get advice from other knowledgeable people that share the same interest.…

  3. Mujer – Planos Calza PUMA Zandy Mesh Wn’s Fluo Rosa/Cabaret/Sharp Verde

    Greetings! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!

  4. prezzi occhiali ray ban 2015

    Informative article, exactly what I wanted to find.

  5. ray ban highstreet prezzo

    I don’t leave many remarks, however after looking at through some of the remarks on %BLOG_TITLE%. I do have some questions for you if you do not mind. Is it just me or do a few of these remarks appear as if they are written by brain dead people? 😛 A…

  6. ray ban collezione 2016

    If you wish for to get a good deal from this article then you have to apply such techniques to your won website.

  7. ray ban sunglasses for men cheap

    Greetings! Very useful advice within this article! It’s the little changes that produce the greatest changes. Thanks for sharing!

  8. oakley radarlock white

    Saved as a favorite, I love your web site!

  9. ray ban wayfarer rb 2140

    Excellent post but I was wanting to know if you could write a litte more on this subject? I’d be very grateful if you could elaborate a little bit more. Kudos!

  10. Mi-Pac x Nyx Deyn Zaino – rosa Palms – Buono

    What i don’t understood is if truth be told how you’re not actually much more well-preferred than you may be now. You are so intelligent. You recognize therefore considerably on the subject of this subject, produced me individually imagine it from so…

  11. Gafas de sol Police popular fábrica de salida de 705.016

    Hey! I know this is kinda off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!

  12. nike air max shoes cheap

    I enjoy looking through a post that will make people think. Also, thank you for permitting me to comment!

  13. venta vans leopardo 2014

    It’s in fact very complex in this full of activity life to listen news on Television, thus I just use web for that reason, and take the most up-to-date information.

  14. Nike SB Elite Skate 2.0 Crew Socks – Bianco / lupo grigio – negozio per la vendita

    Hello! Do you know if they make any plugins to assist with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results. If you know of any lease share. Many thanks!

  15. Venta al por mayor gafas de sol Oakley 2013 la venta Nueva línea 07594

    Very good website you have here but I was wondering if you knew of any forums that cover the same topics talked about in this article? I’d really love to be a part of community where I can get suggestions from other knowledgeable people that share the…

  16. DVS Commanche Skate Scarpe – pelle nera Vero Buck – Favorite

    Hi, i think that i saw you visited my weblog thus i came to ¡°return the favor¡±.I’m attempting to find things to enhance my website!I suppose its ok to use a few of your ideas!!

  17. italia oakley design

    I¡¯m not that much of a online reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your website to come back down the road. All the best

  18. Nike Air Max 90 25TH Anniversary ICE Diamond Hombre Running Zapatos Transparent Red Orange Night Glow Green Online Sale

    Spot on with this write-up, I honestly feel this web site needs much more attention. I’ll probably be back again to read more, thanks for the info!

  19. Occhiali da Sole Maui Jim 502 KAPALUA Uomo Grigio Canna Di Fucile Lucido Polarizzata Outlet S2011

    Hi my loved one! I want to say that this article is amazing, great written and include almost all important infos. I’d like to see extra posts like this .

  20. customized nike shoes for sale

    Excellent beat ! I wish to apprentice while you amend your website, how could i subscribe for a blog web site? The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept

  21. nike air max wright

    Good day! I know this is kinda off topic however I’d figured I’d ask. Would you be interested in trading links or maybe guest writing a blog article or vice-versa? My blog goes over a lot of the same subjects as yours and I think we could greatly ben…

  22. ray ban meteor nederland

    What’s up, its nice article regarding media print, we all understand media is a great source of information.

  23. onde comprar oakley em roma

    I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web smart so I’m not 100% certain. Any suggestions…

  24. nike air max 87 dame zettai

    I got this site from my buddy who informed me about this web site and now this time I am visiting this web site and reading very informative content at this place.

Leave a Reply

You must be logged in to post a comment.