Basic DIV question

Basic DIV question
0.0 0

#1

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


#3

You can use id attribute

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

#4

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

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

or

<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.


#5

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


#6

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


#7

Hey nickh46

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

Happy coding. :slight_smile:


#8

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


#9

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:


#10

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

<header class=random">

or

<section class="something">

or

<ul id="id-1">

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


#11

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


#12

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