HTML Span

HTML Span starts from <span> tag and ends with </span> tag. HTML Span is used to creating a styling scope in inline element or used for grouping some element for styling. Technically HTML Span has no effect on any html element but with CSS and JavaScript it plays grate role for styling html content.

We can group inline element together by using HTML Span and then we can define common style for them.

HTML Span Syntax

<span>scope of span element, you can style it</span>

Where to use HTML Span

There are several scenarios where we can use HTML Span like within a paragraph if we need some text at some place in different colour or some bold style or if we need to insert icon somewhere in paragraph then we can use HTML Span. There is no limitation to use of HTML Span, it depends on us how we can think and use.

HTML Span Example

<p> As a beginner if you want to start web design then there are 3 things to learn i.e.<span style="font-weight:bold; color:red">HTML, CSS and JavaScript</span>. Without knowledge of these things you can not be a professional web developer. </p> 

Result

As a beginner if you want to start web design then there are 3 things to learn i.e.HTML, CSS and JavaScript. Without knowledge of these things you can not be a professional web developer.

HTML Span Attribute

We can use many global and local attribute with HTML Span but generally we use 2 attributes id and class because if we want to common style at many places in a web-page then it’s better to define same class name for each span and write common style at a single place instead of multiple class name or inline style.

HTML Span Attribute Example

<head>
  <style type="text/css">
     .myspan{
        font-size:20px;
        color:blue;
        font-weight:bold;
      }
  </style> 
</head>
<body>
  <p>In final examination <span class="myspan">Mau scored 580 </span> marks out of 600, because of that she becomes the topper of class.</p>
  <p>In same exam <span class="myspan">Sam scored only 98 marks</span>, it is the worst performance by any student of our college.</p>
</body>

Result

In final examination Mau scored 580 marks out of 600, because of that she becomes the topper of class.

In same exam Sam scored only 98 marks, it is the worst performance by any student of our college.

Policy

GDATAMART.COM is optimized for learning & job information; The users try to improve your knowledge and practical experience through this site but we cannot warrant full correctness of all content... Learn More → | Sitemap →

© 2020 GDATAMART | All Rights Reserved