Basic DIV question

Hello People,

I am going to ask a very basic DIV question because I want to get some clarity. If I create two or three DIV sections how do I differentiate one from the other. For example, I want one paragraph to be formatted one way using DIV and another paragraph another way, using another DIV.

The reason for this is because I am just learning about DIV and how to use the property correctly. I had a problem in that I wanted one part of my site to do one thing and another to do something else. However, when I used the DIV property I found everything related to that ONE Div property.

Hope that makes sense

1 Like

You can use id attribute

<div id="div-1"></div>
<div id="div-2"></div>
<div id="div-3"></div>
1 Like

The best way to differentiate your DIV’s is by giving them a class or id attribute. For example:

<div class="random"> </div>


<div id="something"></div>

This way later in your code when you are trying to get your DIV’s to do different things, you can format your code according to the class or id names.


Hi Aditya2000

Thank you - I did wonder if this was something I could do. So I am pleased to know I am thinking in the same way - as a coder! That has given me a lot of confidence.

Thank you

1 Like

Hi Jonfuen21,

And thank you too. That has clarified quite a few things. I wasn’t sure how classes worked but I think I am actually sure how they work, just not confident to code them. Now I can see I was thinking in the correct way.

Thanks very much

Hey nickh46

You are welcome. I’m glad to know that it was helpful for you.

Happy coding. :slight_smile:

1 Like

I really love coding and getting advice from people like you is invaluable. Really so helpful!

1 Like

I’m also a learner like you I’m not so good programmer. I’m also struggling with things like you are and it’s usual.
By the way I’m pleased to help you :smile:

1 Like

No problem, a good tip to keep in mind is you can assign classes and id’s to anything. For example:

<header class=random">


<section class="something">


<ul id="id-1">

Once you get more comfortable with coding this will definitely come in handy.

1 Like

thank you very much. I have just completed one CSS section. Now I am going to try writing a basic web page !

1 Like

thank you too. Yes, I think I am getting the hang of things now. I am going to write a basic web page using CSS and DIVs