I'm using Twitter Bootstrap. I wrote in my html:

<div> asdfashdjkfhaskjdf </div> 

Why the height is not 100px when I open that page?


For posterity, the original code was : <div height="100px">

5

2 Answers

To write inline styling use:

<div> asdfashdjkfhaskjdf </div> 

Inline styling serves a purpose however, it is not recommended in most situations.

The more "proper" solution, would be to make a separate CSS sheet, include it in your HTML document, and then use either an ID or a class to reference your div.

if you have the file structure:

index.html >>/css/ >>/css/styles.css 

Then in your HTML document between <head> and </head> write:

<link href="css/styles.css" rel="stylesheet" /> 

Then, change your div structure to be:

<div> asdfashdjkfhaskjdf </div> 

In css, you can reference your div from the ID or the CLASS.

To do so write:

.someclassname { height: 100px; } 

OR

#someidname { height: 100px; } 

Note that if you do both, the one that comes further down the file structure will be the one that actually works.

For example... If you have:

.someclassname { height: 100px; } .someclassname { height: 150px; } 

Then in this situation the height will be 150px.

EDIT:

To answer your secondary question from your edit, probably need overflow: hidden; or overflow: visible; . You could also do this:

<div> <div> asdfashdjkfhaskjdf </div> </div> 
3
<div> </div> 

OR

<div/> and set the style as #foo { height: 100px; } <div/> and set the style as .bar{ height: 100px; } 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy