2
votes

I am very new to HTML and CSS but while learning I ran into something that I was curious about. How come when you want to style or change font size etc. you use :.

Example: style="color: red; font-size: 50px".

But when you want to link to let's say your stylesheet you use =.

Example: link type="text/css"; rel="stylesheet"; href="stylesheet.css".

What's the difference? Because basically when you say color: red, your saying you want the color to = red, so why not just use that? This is just a curiosity thing nothing serious but your answers are appreciated.

3 Answers 3

2
votes

When you use :, it's CSS. When you use =, it's HTML. It's just two languages with each one has its own different method for assigning attributes (HTML) and properties (CSS).

4
  • Quick response, Thank you. Also thank you for editing my post I don't know how to make it look like that but I'll figure it out and make sure future post are easier to read. Feb 18, 2014 at 21:29
  • No problem and welcome to Pro Webmasters.
    – Zistoloen
    Feb 18, 2014 at 21:37
  • 3
    Neither HTML nor CSS has variables; they are not programming languages. HTML has attributes, CSS has properties. But it is indeed a matter of simple syntactic difference between the two languages. Feb 18, 2014 at 21:44
  • @Jukka K. Korpela: You're right, I have edited my answer.
    – Zistoloen
    Feb 19, 2014 at 8:38
1
vote

Each programming language has its syntax.

For HTML, styles' properties are defined by

property_name: property_value 

And also for HTML, markup properties are defined by

markup_name = markup_value
1
vote

Every Language has its own syntax and structure and in html assignment is done using "=" and in css assignment is done using ":" .

Example:

In css

  body {
  background-color: lightblue;
}

In Html

bgcolor="red"

but in css you can use : for selecting specific element from html

Example:

input:checked {
  height: 50px;
  width: 50px;
}

This css is applied when input is checked

Not the answer you're looking for? Browse other questions tagged or ask your own question.