Jump to content

<div1> within <div>


joemorris86

Recommended Posts

Hey guys, I've been following the tutorials on the site to try and learn html5 and css2/3.So far Its been going ok, But i have hit a snag and I cant seem to find the answer on google. That or I just didn't understand it.When I put a div within a div, it works fine, looks how it should, but when I validate it as html5 it comes up with errors.Im putting 4 divs instead a big div, and using floats to have them side by side.A demo of it is at: http://www.cloudll.co.uk/testdir/01/Here is the basic bit of my code, could anyone tell me how I can change it so it validates.Thanks for any help :)

<div><div3><h2>Header</h2></div3><br /><div1><h1>stuff</h1></div1> <div2><h1>stuff</h1></div2><br class="clear" /><br /><div1><h1>stuff</h1></div1><div2><h1>stuff</h1></div2><br class="clear" /></div>

Link to comment
Share on other sites

There's no element called <div1>, <div2>, <div3> or <div4>. You have to give them classnames if you want to style them individually. For example <div class="first"> or <div class="second">In CSS, access classes using the dot.

.first { width: 400px; }

Link to comment
Share on other sites

There's no element called <div1>, <div2>, <div3> or <div4>. You have to give them classnames if you want to style them individually. For example <div class="first"> or <div class="second">In CSS, access classes using the dot.
.first { width: 400px; }

Thanks for the fast reply :)Sorry if this next question sounds really dumb, but if I set my css like <div class="first">, how do I close it at the end?I have changed them all now in my code but haven't closed anything so they are a little all over the place:http://www.cloudll.co.uk/testdir/01/Should I do it like this? <p class="first"> html </p>
Link to comment
Share on other sites

Obviously, you have to close all open tags.

<div class="first"> </div><div class="second"> </div>

Or even if they're nested:

<div class="first">  <div class="second"> </div></div>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...