Tech Junkie Blog - Real World Tutorials, Happy Coding!: CSS : HTML Selectors

Tuesday, April 3, 2018

CSS : HTML Selectors

In CSS you can define styles for HTML elements and apply the styles globally on the page where the HTML element is used.  For example you can define styles for the entire html element or the p element.  Like the following markup


        html {color:blue;}
        p {font-weight:bold;}
        h1 {color:red;}


This is a paragraph

This h1 tag




You can also group your selectors by using commas to define a style for more than one element. Like h2, h3 {color: blue;}

This is h2

This is h3


So far we have define one declaration at a time. But in CSS we can chain together more than one declaration for each element. Let's say we want to make our h4 element a little bit more fancy by combining multiple declarations together.
h4 {font: 12px Ariel; color: green; background: yellow;}

This is the h4 style





2 comments:

Search This Blog