Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DIV tutorial

Featured Replies

Hello!

 

Ive looked through the forum and ive looked at probably 50 different tutorials about css/html but none of them really explains about div.

 

Im after a tutorial that explains DIV from the bottom! Most tutorials mention DIV but only short and they do go through it at all.

 

So if you know any please tell me :)

 

Regards Hansen

A HTML DIV tag is for dividing parts of a document into DIVisions. An example page might have three divisions

 

Header

Content

Footer

 

and translated into HTML would look like this...

 

<div>
<h1>My heading</h1>
</div>
<div>
<p>My content</p>
</div>
<div>
<p>My footer</p>
</div>

 

But, that code doesn't have the DIV tags doing anything useful so we add a CSS class to each...

 

<div class="header">
<h1>My heading</h1>
</div>
<div class="content">
<p>My content</p>
</div>
<div class="footer">
<p>My footer</p>
</div>

 

Now you can use CSS to style each DIV independantly, colours, borders, backgrounds, padding, margin, width, alignment etc.

 

And that really is DIV in a nutshell, there's not much more to it than that.

To add to Blue's comment, and not wishing to confuse further, you could also use an ID for the DIV (and probably should). This indicates that that section of code is unique within the web page and allows you greater scope for styling. Just substitute the CLASS for an ID.

 

For reference the CLASS tag should be used where the same style need to be applied to several elements on the page (eg: a photo portfolio where each photo has the same styling).

 

My two-penneth.

As it happens I'm writing a tutorial on CSS layout at the minute, which covers DIVs in depth, like my other CSS tutorial (see my sig) it is aimed at absolute beginners.

  • 1 month later...

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.