Appendix E. Hexadecimals


E. Hexadecimals

"Regular" numbers are based on the base 10 system, that is, there are ten symbols (what we call "numbers"): 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. To represent numbers greater than 9, we use a combination of these symbols where the first digit specifies how many ones, the second digit (to the left) specifies how many tens, and so on.

In the hexadecimal system, which is base 16, there are sixteen symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f. To represent numbers greater than f (which in base 10 we understand as 15), we again use a combination of symbols. This time the first digit specifies how many ones, but the second digit (again, to the left) specifies how many sixteens. Thus, 10 in the hexadecimal system means one sixteen and no ones. In the base 10 system, it'd be 16.

In (X)HTML and CSS, hexadecimal numbers are used to define colors (see page 126) and to insert symbols (see page 336). While you can convert hexadecimal numbers by hand, I've also included a table to help you quickly look up a number's hexadecimal equivalent.

Figure E.1. Hexadecimal numbers are base 16, that is the first digit (starting on the right) represents the ones, the second digit represents the 16's, the third digit represents the 256's, and so on.


Hexadecimal Equivalents

#

Hex.

#

Hex.

#

Hex.

#

Hex.

#

Hex.

#

Hex.

#

Hex.

#

Hex.

0

00

32

20

64

40

96

60

128

80

160

A0

192

C0

224

E0

1

01

33

21

65

41

97

61

129

81

161

A1

193

C1

225

E1

2

02

34

22

66

42

98

62

130

82

162

A2

194

C2

226

E2

3

03

35

23

67

43

99

63

131

83

163

A3

195

C3

227

E3

4

04

36

24

68

44

100

64

132

84

164

A4

196

C4

228

E4

5

05

37

25

69

45

101

65

133

85

165

A5

197

C5

229

E5

6

06

38

26

70

46

102

66

134

86

166

A6

198

C6

230

E6

7

07

39

27

71

47

103

67

135

87

167

A7

199

C7

231

E7

8

08

40

28

72

48

104

68

136

88

168

A8

200

C8

232

E8

9

09

41

29

73

49

105

69

137

89

169

A9

201

C9

233

E9

10

0A

42

2A

74

4A

106

6A

138

8A

170

AA

202

CA

234

EA

11

0B

43

2B

75

4B

107

6B

139

8B

171

AB

203

CB

235

EB

12

0C

44

2C

76

4C

108

6C

140

8C

172

AC

204

CC

236

EC

13

0D

45

2D

77

4D

109

6D

141

8D

173

AD

205

CD

237

ED

14

0E

46

2E

78

4E

110

6E

142

8E

174

AE

206

CE

238

EE

15

0F

47

2F

79

4F

111

6F

143

8F

175

AF

207

CF

239

EF

16

10

48

30

80

50

112

70

144

90

176

B0

208

D0

240

F0

17

11

49

31

81

51

113

71

145

91

177

B1

209

D1

241

F1

18

12

50

32

82

52

114

72

146

92

178

B2

210

D2

242

F2

19

13

51

33

83

53

115

73

147

93

179

B3

211

D3

243

F3

20

14

52

34

84

54

116

74

148

94

180

B4

212

D4

244

F4

21

15

53

35

85

55

117

75

149

95

181

B5

213

D5

245

F5

22

16

54

36

86

56

118

76

150

96

182

B6

214

D6

246

F6

23

17

55

37

87

57

119

77

151

97

183

B7

215

D7

247

F7

24

18

56

38

88

58

120

78

152

98

184

B8

216

D8

248

F8

25

19

57

39

89

59

121

79

153

99

185

B9

217

D9

249

F9

26

1A

58

3A

90

5A

122

7A

154

9A

186

BA

218

DA

250

FA

27

1B

59

3B

91

5B

123

7B

155

9B

187

BB

219

DB

251

FB

28

1C

60

3C

92

5C

124

7C

156

9C

188

BC

220

DC

252

FC

29

1D

61

3D

93

5D

125

7D

157

9D

189

BD

221

DD

253

FD

30

1E

62

3E

94

5E

126

7E

158

9E

190

BE

222

DE

254

FE

31

1F

63

3F

95

5F

127

7F

159

9F

191

BF

223

DF

255

FF


So, to use this chart, imagine you want to find the hex value for a color with 35% red, 0% green, and 50% blue. The percentages are relative to 255, so 35% x 255 = 89. Now, find the hexadecimal equivalent of 89, near the bottom of the third column above. So for red, we have 59. Green is easy; 0 = 00. For blue, we again have to multiply the percentage by 255 to get the numerical value. 50% x 255 is 127 (more or less). Then find the hex value for 127, at the very bottom of the fourth column. So, the blue is 7F. The final step is to write it all together: #59007F, which will get us a fine dark purple, precisely 35% red, 0% green, and 50% blue.




HTML, XHTML, & CSS(c) Visual QuickStart Guide
HTML, XHTML, and CSS, Sixth Edition
ISBN: 0321430840
EAN: 2147483647
Year: 2004
Pages: 340

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net