Css targets specific div tags on a large HTML page

Regarding my previous question here . If I use the HTML below as part of my webpage, where there are likely to be many other div tags, how can I target these individual divs in my CSS? The pattern that I think works best [This Answer] [2].

I added identification attributes to make divs more accessible in the large HTML DOM ... I don't know how else to make them more distinguishable. If there is a better way to do this, please let me know. The goal is to apply CSS design to about 6 div tag elements on the portal website with a lot of points. If there is a more general way that will be cool, so I can easily add additional sections and use this format in the future ... I can add a class attribute for each element to which I want to apply formatting, but I don't know the syntax.

What is a professional web designer for this?

<div id="projectName">
       Realtime Account Activiation
</div>

<div id="divAnnounce">
        Announcements
</div>

I have http://jsfiddle.net/eW532/1/

, , , . , html .

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .even_spacing {  color: purple;
                        background-color: #d8da3d }

        .first_letter {  background:blue;
                        color:white;
                        padding:4px 0px 4px 5px;}           
  </style>

</head>
<body>
    <form id="form1" runat="server">

    <div class="first_letter even_spacing">
        Realtime Account Activiation
    </div>

    <div class="first_letter even_spacing">
        Announcements
    </div>
    </form>
</body>
</html>
+5
6

HTML put <LINK REL=StyleSheet HREF="Path/to/your/stylesheet.css" TYPE="text/css" MEDIA=screen> , .

CSS:

#projectName{
style:value;
}

#divAnnounce{

}

# , . ,

, ,

#idname.classname{

}

div divAnnounce,

#divAnnounce #yournewdiv{

}

#divAnnounce div{

}

#newdivid{

}

, ,

+5
<style>
.class1 {
style: value;
}

.class2 {
style:value;
}
</style>

<div class="class1" id="projectName">
       Realtime Account Activiation
</div>

<div class="class2" id="divAnnounce">
        Announcements
</div>

:

+2

.

CSS DIV

, .

, CSS "Access-Control-Allow-Origin" .

CSS , applyCSSToHTML().

!

+1

CSS .

0

.className #IDName :

.className {
style:value;
}

#IDName {
style:value;
}
<div class="className">Test</div>

<div id="IDName">Test</div>
0

Identifiers are unique; they serve to identify a specific element of the page. So this is really the best way to achieve what you are looking for!

Style setting example:

#projectName {width:100%;}

Example of setting a jQuery event:

$("#projectName").click(function() { alert('Clicked'); });
-1
source

All Articles