{ LearnWebSiteDesign.com }
HTML, HTML5, XHTML, CSS and CSS3 Tutorials
CSS Selectors Tutorial
Selectors are used to select the HTML element on an HTML document that can be styled.
Universal Selectors
The universal selector is an asterisk (*). When used alone, it tells the CSS intrepreter to apply the CSS rule to all HTML elements in the HTML document.
The code example below shows you how use a universal selector:
Type Selectors
CSS type selectors specify the HTML tag or HTML element to style.
For example, to style all paragraphs within an HTML document, you would specify the paragraph tag (p) within the CSS rule as shown below:
The code example below shows you how to specify that all level 1 headings (h1) within an HTML document are to be styled.
Class Selectors
Class selectors can be used to specify a style for an HTML element or a group of HTML elements which the HTML elements have the corresponding class attributes.
A dot (.) begins a class name selector in the style sheet. The class name is any name that you make up and should be made up of of only letters, numbers and/or hyphens, since this provides the best compatibility with older web browsers. The class name is included in the HTML document with the use of the class attribute.
NOTE: Do Not start a class name with a number. Only Internet Explorer accepts class names that start with a number.
The code example shows you how to use class selectors.
In the code example below, the paragraphs and headings with the class name of red are targeted and styled with the class selector .red.
In the code example below, only the paragraphs with the class name of red are targeted and styled with the class selector .red.
Combining Type and Class Selectors
You can combine type and class selectors.
The code example below shows you how to combine type and class selectors.
Combining Multiple Classes
Multiple classes can be applied to one HTML element.
The code example below shows you how to apply more than one class selector to one HTML element.
ID Selectors
The ID selector are similar to class selectors, however, they are meant to specify a single, unique element to style. They are meant to be applied only once per HTML document. In comparison, class selectors are meant to be used however many times that you like within an HTML document.
The ID selector is used to select any HTML element that has the corresponding ID attribute and is defined with a number (#) sign (also called a pound sign).
The code example below shows you how to use ID selectors.
Class Selectors or ID Selectors?
Since class selectors are meant to be used multiple times within HTML documents, you should reserve using ID selectors, for example for the use of ID selectors to style the layout of web pages.
Tutorials
Templates
References
Sponsors
You can get your website online using Velnet, a leading UK web hosting provider. They provide free template and installation for WordPress blogs. Discuss webmaster related topics at Webmaster Serve, a Webmaster SEO forum
SouthernWebGroup.com provides high quality website design in Atlanta, GA as well as around the world.
Find low cost cheap website hosting and domain registration.
Browser our free no ads web hosting directory and find the free web hosting that's right for you and your budget.
Advertise your web design and web development related products and services here.
- Web Hosting UK
- Web Design Manchester
- Cheap Web Hosting
- free website hosting reviews
- ecommerce design
- Advertise
Recommended
Download free css web hosting templates that are easy to edit at FreeWebHostingTemplates.com.
Friends
- free web hosting templates
- free web hosting templates
- free web hosting reviews
- Web Development
- HD Wallpapers
- best web hosting providers
- Web Hosting Blog
- domain names
- iPage Host Reviews
- Reliable Bluehost Reviews
- Programming Forum
- Alojamento Web
- criar sites
- Free Facebook Banners
- Free No Ads Web Hosting Reviews
- Cheap Web Hosting Reviews
- Free Web Hosting Templates
- Free Premium Wordpress Themes
- Free Premium Wordpress Themes
- Free Joomla Template
- Free Wordpress Themes
- Best Android Apps
- Wordpress Themes Gallery
- Information technology courses
- Free PSD Files