CSS Syntax- Tutorialpath

CSS is a 3-part process:

  • the selector defines who is targeted, which HTML element(s) like <h1> or <table> etc.
  • the property defines what charateristic to alter like color, border etc.
  • the value defines how to alter that charateristic like red or #F1F1F1, solid etc.

You can put CSS Style Rule Syntax as follows −

selector { property: value }

Selectors With HTML tag


Selectors With Class Name

 

Selectors With Tag Id

 

Child Selectors

There is one more type of selector, which is very similar to descendants but have different functionality.

 

Attribute Selectors

You can also apply styles to HTML elements with particular attributes. Like-

 

Multiple Style Rules

You may need to define multiple style rules for a single element. Follow this example-

 

Group Selectors

You can apply a style to many selectors if you like. Just use comma to separate the selectors.


		

Leave a Reply

Your email address will not be published.