What is id = name = .something #something?
- ID: unique identifier of the DOM element
- Name: the name that will be used when submitting the form, which is used as the data search key.
#something: link to the element with the identifier 'something'.something: link to an element with the class name "something"
These are some really basic concepts of HTML and CSS. You probably want to read the basic HTML tutorial to learn more about this, especially.
CSS JavaScript. :
HTML:
<button id="foo">Click me to unleash the Unicorn</button>
CSS
#foo {
border: 1px solid #ff0000;
font-weight: bold;
background: #000;
color: #fff;
}
JavaScript:
document.getElementById('foo').onclick = function() {
var img = document.createElement('img');
img.src = 'http://display.ubercomments.com/6/23672.jpg';
document.getElementsByTagName('body')[0].appendChild(img);
};
a class is a multiple selector, for example, if you want many tables to have the same colors, background colors and background font, etc. You define a class. In these tables, if a particular table needs to be styled differently, you will use id. The identifier cannot be duplicated. And you can assign the same class as many objects that you want.
<style type="text/css">
.MyTable{
background-color:#ff00ff;
}
#centralTable{
background:color:red;
}
</style>
<div class="MyTable">Data </div>
<div class="MyTable"> </div>
<div class="MyTable" id ="centralTable"> Data</div>
<div class="MyTable"> Data</div>
<div class="MyTable">Data </div>
Remember that cascading style sheets are followed by period ( .) and identifiers ( #).