After saving a rich field in Microsoft Sharepoint, I noticed that a new "External Class" was automatically added to my CSS

Although I am new to Sharepoint, I have experience in HTML and CSS. I recently created a mini HTML application that changes the pictures of hyperlinks on hover. It works perfectly when run on a normal browser outside of Sharepoint.

However, the issue arises when I try to embed the code in a rich field within Sharepoint. Despite working in "edit mode", the code does not function after saving. Additionally, Sharepoint generates an "ExternalClass" next to each of my CSS objects once saved. Could this be the reason why my code is not working after saving? What modifications is Sharepoint making to my HTML code? Is there a solution to this problem? Any guidance would be greatly appreciated.

Original:

            <style type="text/css">
                        #map
                        {
                                   width:663px;
                                   height:715px;
                                   background-image:url("/sites/00172/SiteAssets/Germany1-Standard.png");
                        }
                        #Bremen
                        {
                                   position:absolute;
                                   width:37px;
                                   height:53px;
                                    top:359px;
                                   left:243px;
                                   background-image:none;
                        }
 
                        // Remaining CSS code omitted for brevity
 
            <div id="map">
                        <a href=...>
                        </a>
                        
                         // Remaining html code omitted for brevity   
            </div>

After Saving in Sharepoint:

            <style unselectable="on">
AFC97320FBA74F4E88F2B1AD1F833E02 .ExternalClass #map {
width:663px;
height:715px;
}
 
                // Omitted CSS for other elements due to space constraints
 
</style>
 
<div id="map" unselectable="on">
                        <a title="Bremen" id="Bremen" href="/sites/00172/Lists/Calendar01/calendar.aspx">
                        </a>
                      
                            // Omitted html code for other links for conciseness
                        
            </div>

Answer №1

When inputting HTML code directly into a Content Editor web part, SharePoint automatically sanitizes the code to prevent any conflicts or issues.

To keep your HTML/CSS/JavaScript unchanged in SharePoint, save it as a text or HTML file in a document library and then use the "content link" property of the Content Editor web part to embed the file without altering the original markup and code.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What strategies can I implement to stop Iframes from disrupting the browser's history when interacting with them?

In my particular situation, I utilize Iframes to display Grafana on my page, which showcases beautiful and user-friendly graphs. After examining, I noticed that interactions like zooming in or out on the graph using mouse clicks trigger a type of refresh ...

Scaling the ion-spinner to fit your specific needs

In my Ionic application, I am utilizing the ion-spinner. However, I have encountered an issue with resizing the spinner. While custom CSS works well with default spinners, it does not function properly with Bubbles, Circles, and Dots spinners. CSS .spin ...

I was able to resolve the fixed position issue of a button on Safari for iPhone 3G

Here is the setup I have on jsfiddle: http://jsfiddle.net/zZDqH/ Currently, there is a button fixed at bottom:0px. You can scroll up and down the page, and the button will stay at the bottom of the page. However, when testing in Safari on an iPhone 3G ( ...

An easy guide to automatically refreshing a div with a seamless animation

I am working on an HTML page where I want to smoothly refresh a specific div every 60 seconds. What I have in mind is a simple process: fade out the div / refresh the div / fade in the div However, despite reading extensively about jQuery and AJAX for r ...

Linking URLs in an Android TextView with the <a href> tag

When creating a TextView dynamically, I encountered an issue with setting the text as linkable. The desired text value was "Google". After referring to various resources on the internet and blogs, such as this one, I attempted different methods but did not ...

What is the option for receiving automatic suggestions while formatting components in a react.js file?

When styling elements in our app using app.css or styles.css, VS Code provides auto-suggestions. For example, if we type just "back" for background color, it will suggest completions. However, this feature does not work in react.js or index.js. Why is that ...

I am attempting to draw a correlation between two numerical variables

I'm struggling to compare two scores in my game. When they match, I want it to display "You won", but I can't get it to work. I've attempted using the parseInt method and .val method, but no luck so far. var numberFour = Math.floor(Math.ra ...

Tips for breaking out of an infinite loop while loading HTML containing a carousel into a blank <div> within another HTML file using jQuery's $(document).ready() function

Currently, I am studying HTML, CSS, Bootstrap 4, jQuery3, and JavaScript (ES6+), and to enhance my skills, I have devised an exercise for practice and consolidation. I have created 4 HTML files, all featuring responsive design based on Bootstrap 4: inde ...

Add small pieces of content to CKEditor

Is there a way to add "atomic" block content into CKEditor? For instance, I would like to add <h1>Test</h1> right after the letter "B" in the sentence <p>A B C</p>. Currently, when using CKEDITOR.currentInstance.insertHtml('&l ...

Is it possible to implement the 'opacity' feature on the homepage of my HTML website?

I am currently working on my website and I would like to display a notice to members when they open the site. This notice should only appear once, right above the HTML homepage, as the homepage content may vary for different members. I plan to use 'op ...

What is the best way to display a placeholder instead of the state's value when a page loads?

I'm having trouble displaying the placeholder of an input instead of its state value. When the page loads, it shows an empty select box because the testType state is null initially. How can I make sure that only the placeholder is shown instead of the ...

What strategies can be implemented to minimize the impact of HTML code on just one specific div (or any other chosen element)?

<div> <b> some example </div> different content This will make the "different content" bold. Is there a way to restrict the impact of <b> only to the <div> element? I have tried looking for JavaScript solutions online but did ...

What is the process to discover, upload, and implement a custom font?

In my quest to locate and incorporate a font named neontubes, or if not available, a font called freestyle script, I have learned that I must obtain an src which is then included in my style.css file and subsequently designated in the styling rule like s ...

Executing functions in TypeScript

I am facing an issue while trying to call a function through the click event in my template. The error message I receive is "get is not a function". Can someone help me identify where the problem lies? This is my template: <button class="btn btn-prima ...

What could be causing the disappearance of the replaced div content after a refresh?

Does anyone have experience with using jquery in conjunction with django? I am currently trying to update the content of a div after successful user authentication. While my code is functional, I'm facing an issue where upon page refresh, it reverts b ...

What is the best way to merge two JSON values with the help of jQuery?

Two JSON Objects are provided below: The first one is: [{ "id": 5001, "count": "0", "type": "None" }, { "id": 5002, "count": "0", "type": "Glazed" }, { "id": 5005, "count": "0", "type": "Sugar" }, { "id": 5003, ...

How does Firefox still autocomplete even with a different input label?

How does Firefox decide where to autofill passwords and usernames? I've noticed that even after changing the name, id, title, or class of an input element, Firefox still automatically fills it with my password or email address. ...

Is it possible for me to include &x&y&z in my Sass code?

When working with Sass, I have the following code: asdf{ &-b&-c {font-size: 16px;} } And I want the generated CSS to look like this: asdf.asdf-b.asdf-c{ font-size: 16px; } Is it possible to achieve this in Sass without having to repeat th ...

An easy way to incorporate a fade-in effect for every word in a text

I am trying to make the text "Eat. Sleep. Repeat." slide up and fade in one word at a time. I have experimented with various methods like anime.js, keyframes, and adding css classes, but so far none of them have worked for me. Here is the code I currently ...

Grab the table headings from an HTML table and store them in variables after accessing the DOM

Looking to modify the structure of the DOM. Wanting to display table content using paragraphs instead. To achieve this, I need to extract data from each row in the table. How can I accomplish this task? <table style="width:300px"> <tr> ...