I am looking to insert some HTML elements into my document that will not have any predefined style. It is crucial that these elements maintain a consistent appearance across different projects and webpages. These elements will be added dynamically to the page using JavaScript, specifically as SPANs.
The plan is to use SPAN tags to apply styling to specific text snippets within the document. However, there is a concern that pre-existing styles on SPAN elements could interfere with the desired outcome.
Imagine I am developing a Widget that could potentially be utilized in various webpages. As a result, direct modification of element styles, such as altering stylesheets, is not feasible. The solution needs to be implemented using JavaScript without relying on jQuery.
<head>
<style>
span{
font-weight: bold;
/*additional styles can be added here*/
}
</style>
</head>
<body>
<span class='a_regular_span'>This text should appear bold with additional styling</span>
<span>This text should only display the CSS rules applied via JavaScript, without inheriting global SPAN styles from the page</span>
</body>
Any suggestions or solutions?