एचटीएमएल कंप्यूटरकोड
In this page:
<code>Inline code</code>
<pre><code>Preformatted code</code></pre>
<kbd>Keyboard input</kbd>
code Tag
code tag inline code snippets या technical keywords दिखाने के लिए इस्तेमाल होता है। यह text को आस-पास के body paragraphs से अलग दिखाने के लिए एक monospace font (जैसे Courier) में style करता है।
उदाहरण: The code Tag
<p>Run the <code>npm install</code> command.</p>
Preformatted Code Blocks (pre और code)
किसी multi-line code block को उसके original line breaks, indentation, और spaces के साथ दिखाने के लिए, आप अपने code element को एक pre (preformatted) tag के अंदर wrap करते हैं।
pre tag के बिना, browser आपकी सारी सावधानीपूर्वक की गई indentation और line breaks को एक ही लाइन में collapse कर देगा।
उदाहरण: Preformatted Code Blocks (pre and code)
<pre><code>function add(a, b) {
return a + b;
}</code></pre>
Keyboard Inputs को Style करना (kbd)
kbd element user के keyboard inputs, जैसे command shortcuts या दबाई जाने वाली keys, को represent करने के लिए इस्तेमाल होता है।
Browsers kbd tags के अंदर के text को default रूप से एक monospace font में render करते हैं। इससे 'press Ctrl+S' जैसे instructions को सामान्य body text से visually अलग पहचानना आसान हो जाता है।
उदाहरण: Styling Keyboard Inputs (kbd)
<p>Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.</p>
Terminal Output दिखाना (samp)
samp tag किसी computer system, terminal program, या चल रही script process से आए output data को represent करने के लिए इस्तेमाल होता है, और default रूप से text को monospace font में render करता है।
यह आमतौर पर उन tutorials में दिखता है जो कोड के ठीक नीचे उसके program का console output दिखाते हैं।
उदाहरण: Displaying Terminal Output (samp)
<p>The terminal displayed: <samp>Build successful</samp></p>
Code में Variables Define करना (var)
var tag mathematical formulas, code arguments, या technical equations में variables को represent करने के लिए इस्तेमाल होता है। Browser default रूप से text को italicized format में दिखाता है।
यह visual अंतर readers को तुरंत पहचानने में मदद करता है कि किसी example में कौन-से हिस्से placeholders हैं और कौन-से fixed syntax।
उदाहरण: Defining Variables in Code (var)
<p>The formula is <var>x</var> + <var>y</var> = 10</p>
- multi-line code snippets दिखाने के लिए सिर्फ inline code tag इस्तेमाल करना, जिससे formatting टूट जाती है।
- code elements के अंदर brackets को escape किए बिना raw HTML tags (जैसे ) लिखना, जो आपके page layouts को crash कर सकता है।
- kbd और samp को semantic technical notations के बजाय generic styling tags की तरह गलत इस्तेमाल करना।
- code tag inline technical terms, properties, और filenames को monospace font में style करता है।
- multi-line code blocks के अंदर line breaks और spacing बनाए रखने के लिए अपने code tag को pre tag के अंदर wrap करें।
- keyboard inputs represent करने के लिए kbd, system output logs दिखाने के लिए samp, और technical variables style करने के लिए var इस्तेमाल करें।
standard computercode tags और monospace styles सभी web browsers में natively supported हैं।
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: