I’m experiencing an issue with my HTML project where links are opening in new pages, even though I haven’t included any target attributes and there’s no JavaScript code affecting the links. I’ve checked the HTML structure and CSS styles, and everything seems standard.
I have already looked at some other questions with the same issue but I haven’t seen anything that really helps as it may just be my browsers default behaviour (I am using google chrome) but the thing is for my styling I need a new file but for that file to open in the same page is there any way to control it through script?
This is the part of my navigation system I’m referring too-
<li><a href="/addapage.html"><i class="fa-solid fa-note-sticky"></i>+add a page</a></li>
browsers have a predefined way to deal with links. Remember you never write code in a vacuum, the environment in which the code is visualized changes the behaviour. You could try to specify target="_self" or target="_top"
Very sorry for the late reply , I got really busy and didn’t check the question I asked what do you mean by never write code in a vacuum? What is a vacuum? How does the code you provided correct it?
vacuum is a scientific term for and environment with really low pressure, which also imply really low atoms count, almost empty. It doesn’t matter.
You always write code in an environment, a browser, an IDE, or whatever, each has default settings that can slighlty change the predefined features of what you write. In this case, the browser has its own settings on how to deal with opening a link, check the settings of your browser.
I don’t know if the code I provided correct it, you need to try. target="_self" specify that the link should open in the same frame, and target="_top" that it should open in the same window. Read about the target attribute here: