AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
HTML Tutorial

CSS Class and ID, The Difference Between ID and Class

The difference between ID and a Class selector is that an ID selector can be used to identify one element, but, class selector can be used to identify more than one element.
In the CSS, Class selector starts with "." followed by the selector name, and the selector ID starts with "#" followed by the selector name

The Difference Between ID and Class - example

Syntax : selector { property: value }

Example 1:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS Class and ID, The Difference Between ID and Class - example</title>
<meta name="description" content="CSS Class and ID, The Difference Between ID and Class - example - learn The Difference Between ID and Class." />

<style type="text/css">
#header {
background-color: #B0FFB0;
padding: 12px;
font-size: 18px;
font-family: Arial, Helvetica, sans-serif;
}
.main-box {
color: #039;
font-weight: bold;
text-align: center;
padding: 14px;
background-color: #EAEAEA;
margin-top: 16px;
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body>

<div id="header">
Your head title here. This header box is an ID selector.
</div>

<div class="main-box">
<ul>
<li>Text 1</li>
<li>Text 2</li>
<li>Text 3</li>
</ul>
</div>
<div class="main-box">
Here is the second main-box selector
</div>

</body>
</html>

CSS cod above will display this CSS result -

The Difference Between ID and Class

Note: There are no browser defaults for any ID or Class


CSS Class and ID, The Difference Between ID and Class
CSS Class and ID, The Difference Between ID and Class - css tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


CSS Scrollbar Horizontal
CSS Scrollbar in Div
CSS Scrollbar Firefox
CSS Style Scrollbar
CSS Style Text
CSS background color
CSS Div Id Class
CSS Text Wrap
CSS text-align
CSS Text Decoration
CSS Text Shadow
CSS Text Color
CSS Text Bold
CSS Text Size
CSS background image full
CSS background opacity
CSS border radius
CSS rounded corners
CSS font color
CSS Class & ID
CSS align image center
CSS align content
CSS link color
CSS Text Style
CSS Text Font Size
CSS max width &height
CSS width and height
CSS Margin
CSS Padding
CSS Border Style
CSS background
CSS in HTML
Basic Syntax of CSS
CSS Introduction
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


PHP convert array to string with commas...
PHP array to comma separated string with...
How to put text in image HTML...
How to insert text in html code using ja...
PHP array_key_exists() Function...
Bootstrap Templates...
Bootstrap Text...
Bootstrap Accordion...
Bootstrap Scrollspy...
Bootstrap Carousel...
Bootstrap Modal...
Bootstrap Responsive Layout...
Bootstrap Fluid Layout...
Bootstrap Fixed Layout...
Bootstrap Grid...
Bootstrap Input...
Bootstrap Icon...
Bootstrap Dropdown...
Bootstrap Navigation Bar...
Bootstrap Pagination...