How To Make CSS IDs

This article presents relevant facts on CSS IDs, their uses, how they are made and how they compare with CSS class commands.

CSS IDs are used to give special effects to elements in an HTML file that will only have to appear once and cannot be utilized again within the x(HTML) document. Class selector is utilized mainly if you want o influence a number of elements.

When To Use IDs

CSS IDs are used if it is desired that only one element within the HTML document could have a particular style applied. As an example, you may wish to designate an ID to a

tag containing your right menu. The background color, margin, border, alignment, padding are some of the particulars contained in this ID. Once CSS IDs are used, no other element in the HTML document being coded could contain that specific designation. The Document Object Model (DOM) can be utilized to refer about CSS IDs. Through this, you can use DHTML or Java Script methods to create a better interactive web page.

How To Make CSS IDs

Every website has its own identifiers be it for files, folders, and links and these are designated accordingly. This gives you ease in finding divisions in your page. If it is desired to style a certain section in your website in a particular way, you can because the CSS IDs are unique in each webpage. The foremost content for this page is defined by the following:

<div id="content">

 

The content desired is within this division:

.

The „content” CSS ID is selected over a class, since it is going to be used on a sole basis within the HTML document. Then in the CSS file I have the following:

#content{

width: 70%;

margin: auto;

padding: 15px;

border: 3px solid #3433;

background: #ggggg;

}

 

It is observed that the CSS ID selector starts with a „#” or hash symbol. The CSS class selector used (.) period instead.

Comparing CSS Class And CSS IDs

CSS IDs have a superior rank of specificity than CSS classes. This is useful in creating strong reference positions for succeeding selectors while still sticking to common element policies.

The CSS ID prompt functions closely in similar ways as the CSS class. The basis for its existence is that it permits you to include these Style Sheet forms into DHTML or Java Script. Except if you are trying to employ these models with JavaScript, stay fixed with the class commands. You can employ CSS ID commands, however in terms of making a difference in the results; it doesn’t fare better than the class command. Both CSS class and CSS ID codes can be utilized on the same HTML document.

Post navigation