677
votes
19answers
585k views

How to center a div in a div - horizontally?

How do I horizontally center a div in a div with CSS (if it's possible at all)? The outer div has 100%: <div id="outer" style="width:100%"> <div id="inner">Foo foo</div> ...
240
votes
16answers
156k views

Make a div fill the remaining screen space

I am currently working on a web application, where I want the content to fill the height of the entire screen. The page has a header, which contains a logo, and account information. This could be an ...
148
votes
17answers
166k views

Make a div into a link

I have a <div> block with some fancy visual content that I don't want to change. I want to make it a clickable link. I'm looking for something like <a href="…"><div> … ...
125
votes
13answers
281k views

How to align a <div> to the middle of the page

I have a div tag with height set to 800px. When the browser width is greater than 800px, it shouldn't stretch the div but it should bring it to the middle of the page.
110
votes
7answers
215k views

CSS div element - how to show horizontal scroll bars only?

I have a div container and have defined its style as follows: div#tbl-container { width: 600px; overflow: auto; scrollbar-base-color:#ffeaff } This gives me both horizontal and ...
104
votes
9answers
107k views

Make div 100% height of browser window

I have a layout with two columns. Left div and a right div Right div has a Grey background color, and I need it to expand vertically depending on the height of the user's browser window. Right now ...
83
votes
21answers
48k views

How to prevent long words from breaking my div?

Ever since switching from TABLE-layout to DIV-layout, one common problem remains: PROBLEM: you fill your DIV with dynamic text and inevitably there is a super-long word that extends over the edge of ...
78
votes
6answers
102k views

How do you easily horizontally center a <div> using CSS?

I'm trying to horizontally center a <div> block element on a page and have it set to a minimum width. What is the simplest way to do this? I want the <div> element to be inline with rest ...
76
votes
12answers
35k views

How do you get the footer to stay at the bottom of a Web page?

I have a simple 2-column layout with a footer that clears both the right and left div in my markup. My problem is that I can't get the footer to stay at the bottom of the page in all browsers. It ...
64
votes
10answers
107k views

How to Force Child Div to 100% of Parent's Div Without Specifying Parent's Height?

I would assume this is possible, but i just cant figure it out.. i have a site thats basic structure is set up as follows. <div id="header"></div> <div id="main"> <div ...
64
votes
15answers
84k views

How do I force a DIV block to extend to the bottom of a page even if it has no content?

In the markup shown below, I'm trying to get the content div to stretch all the way to the bottom of the page but it's only stretching if there's content to display. The reason I want to do this is so ...
58
votes
3answers
73k views

How to place two divs next to each other?

Consider the following code: HTML: <div id="wrapper"> <div id="first">Stack Overflow is for professional and enthusiast programmers, people who write code because they love ...
51
votes
4answers
59k views

SPAN vs DIV (inline-block)

Is there any reason to use a <div style="display:inline-block"> instead of a <span> to layout a webpage? Can I put content nested inside the span? What is valid and what isn't? It's ok ...
49
votes
11answers
2k views

Am I suffering “divitis”? (CSS especialist needed)

I've read lots of articles that condemn the excessive use of divs. I have a feeling that I might be doing that in the following mark up: HTML: <div id="header"> <div ...
46
votes
9answers
52k views

How to make a div to fill a remaining horizontal space (a very simple but annoying problem for CSS experts)

I have 2 divs: one in the left side and one in the right side of my page. The one in the left side has fixed width and I want the one of the right side to fill the remaining space. The one on the ...

1 2 3 4 5 369
15 30 50 per page