8/9 Div and organise problem


#1

on 8/9, I dont really know why so many div is needed and in div class="#", can the # be some spontaneous words or it is fixed to some limited options.
About organising, Is there anything good advice to help keeping the lines better represented ? I now have to remember how many spaces or tab for each line to show which is inside which.


#2

divs are an organizational tool. If you just like things all tossed into one box, that's fine, but when you want to style three of those things then it will be more difficult.

The class name can be almost anything you want it to be -- there are some rules.

When you first create the div, write both the opening and closing tags at the same time. Add a short comment to the closing tag so you can instantly see which div it belongs to. Like this:

<div class="dazzling">

    <div class="top">    
    </div> <!-- top -->

    <div class="bottom">
    </div> <!-- bottom -->

</div> <!-- dazzling -->

#3

Thank you for the answers. Do you have any link related to the div's name rules?


#4

I wouldn't call these div's names, but instead class names. All of these classes can be used with other elements, not just divs.

<h1 class="dazzling">

I'm having trouble finding a link with a straightforward set of rules. I think that is because things have changed over the years and now most characters are valid even though some will need to be escaped. Here is a link to an SO discussion that started in 2009 but as you read down you will see updates as things have changed.