Sally
Sally

Reputation: 31

What does the "#" mean or stand for in a code?

I'm trying to figure out a coding as a newbie. Wondering what the # symbol means or stands for in a code, like #55555 for a number. Or #menu1 in a div: div#menu1 ul.rMenu?

Trying to back into an education

Upvotes: 3

Views: 573

Answers (6)

Jim Stewart
Jim Stewart

Reputation: 17323

I think people are taking this question a bit too literally and providing answers for those exact two cases.

There is no global convention regarding # in source code. It's a piece of punctuation that doesn't have a conventional use and isn't strongly associated with anything in common use in the English language, so it gets re-used a lot in programming languages.

It's often used to comment out lines (Ruby, Perl, Python, many others):

if foo
  # Do something for foo.
end

It's used in C and C-derived languages to control the preprocessor:

#include <stdio.h>

In addition to the CSS and HTML usages that are already covered.

See Wikipedia for links to many other uses in other programming languages.

Upvotes: 1

ShoibAhamed
ShoibAhamed

Reputation: 359

# is used for elements with some id.

<div id="menu"> ====> div#menu

. for class

<div class="menu"> ====> div.menu

# refers to hex code

Upvotes: 2

cjds
cjds

Reputation: 8426

A. Not Code your talking about CSS http://www.html.net/tutorials/css/lesson1.php

B. Your talking about its use in 2 different instances.

  1. #55555 refers to a color. The # before the number says .. Hey I'm going to tell you a colour now

  2. #menu1 refers to a specific ID. This basically means select an element with that id from in a div

For ex.

<div>
  <div id="menu1">
          Hi
  </div>
</div>

And the CSS would be something like (Color this red)

div #menu1{
     color:#550000; 
}

Upvotes: 0

David Cummins
David Cummins

Reputation: 988

Like many symbols used in programming, the meaning of the symbol is different in different contexts. Below are a few examples:

  • #555555 means a colour (grey in this case) in hexadecimal notation.
  • #menu1 means any tag with the id "menu1".
  • Also other contexts, such as in Cold Fusion #name# means insert the variable named "name".

In general the examples that you're mentioning look like they're from CSS, so feel free to look up CSS:

http://www.w3schools.com/cssref/

Upvotes: 1

BaSha
BaSha

Reputation: 2406

i think in case of #55555 , # indicates hexadecimal code and in case of #menu1 , # indicates menu1 is an ID attribute..

Upvotes: 1

vikbehal
vikbehal

Reputation: 1524

#55555 - Hexadecimal Number.
#menu1 - id of element
div#menu1 - id of element div.

Upvotes: 0

Related Questions