Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to find a way to replace a DIV that has a few other divs inside with another div that also has a few other divs inside. Tried to do it with a few different programs: Atom, Sublime, Visual Studio Code, PhpStorm but it didn't work.
It could probably be done using regex since the first div starts with <div class="short-form"> and ends with
...id="submitbtn_intakeFormShortAutofillSubmit"/>
</form>
</div>
</div>
but my problem is probably the number of tabs, spaces and newlines.
Just to mention, I don't have to make this active on a webpage, but inside hundreds of html pages on my hard drive, so if you can recommend some free software that can do it, it's also good.
Yep, this is very possible! Here's how you do it:
<div class="short-form"[\s\S]*id="submitbtn_intakeFormShortAutofillSubmit"\/>\s*<\/form>\s*<\/div>\s*<\/div>
Break it down!
<div class="short-form" match anything that starts with <div class="short-form"
[\s\S]* matech 0 or more of anything that is white space or is not whitespase (So bassically match anything)
id="submitbtn_intakeFormShortAutofillSubmit"\/> match anything that matches id="submitbtn_intakeFormShortAutofillSubmit"/>
\s* match 0 or more whitespace
repeate the last two a few times!
Here's an example on regexr!
You can use the regex
<div class="short-form">[\s\S]*?id="submitbtn_intakeFormShortAutofillSubmit"\/>\s*<\/form>\s*<\/div>\s*<\/div>
see it live
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I was been told by a colleague of mine that instead of using the br tag we could we could use a span tag and give it a display:block and for the hr tag we could do it with the after pseudo element using css. I have been told that this was a good practice to follow than using these html tags. Is it true for these two cases that this way is preferred over the others or could we use it these two tags itself ?
native html elements are ALWAYS better to use than other weird way to do the same things. The most often, if people don't use <br> and <hr> tags, it's because it doesn't fit the graphic needs.
By the way, creating an <span> tag, just to make a space between two blocks is a horrible way to do it. Use css, even with style !
I would not use <br> for layouting, but only for breaking text mid-paragraph. Still would prefer multiple paragraphs if possible. Instead I would use margins to separate blocks.
On top of #kevinniel's answer, seems like a bad idea to use a <span> (natural inline element) just to change it to a block element (which is the default for <div>'s).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Which is the proper way? Putting more classes in a div or just using a parent div to give the same class to the children within.
Ex. All in HTML file:
<p class="pt-1 fontsize20 text-uppercase bg-black"> text here </p>
Ex. All in CSS file:
<div class="parent">
<p> text here </p>
<p> text here </p>
<p> text here </p>
</div>
css file:
.parent p {
padding-top:10px;font-size:20px;text-transform:uppercase;background:#000;
}
Sorry first post, don't know how to put code in
Part of good programming technique is keeping things DRY (Do Not Repeat yourself).
There are two problems with your first method:
It is not DRY - meaning you will have to repeat that for every paragraph you want it applied to.
You are specifying what it should look like in the class names. Classnames should never represent appearance. For instance you are using the fontsize20 as a class name. That represents the appearance of size 20. If you decide later that you want the font size to be 25, you could change your CSS to 25, but your class name would still say fontsize20. This would be confusing to anyone looking at your code. Instead use class names that are descriptive of the data it contains, not the style it should look like. Ex. class="customer_data" would be a much better class name.
There is no correct way between the 2 ways. Go with whatever the project is using already or pick one of the 2 if there's no currently established method.
To put code in click the {} button or the snippet button to the right of it. Or use 4 spaces to indent and it'll show up in a code block. You can also use tick marks to indicate code like this: display: block;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can I keep this two words on a single line:
<div align=right>hai</div>
<div align=center>hello</div>
I have already tried it but I didn't get any satisfactory preview.
Divs are block elements by default so they will appear on separate lines.
You can set them to inline by css: display:inline
Or use an inline element like or
<span align=right>hai</span>
<span align=center>hello</span>
I'm not sure I correcctly understand your question, but I'll try an answer anyway.
Let's say you have 2 words in a sentance :
<p>word1 word2</p>
and you want this 2 words to be, at any resolution, displayed beside each other.
Replace the space between this 2 words by (code for non-breaking space in HTML), and it will be displayed as a single entity :
<p>word1 word2</p>
If you wanted only DIV tag
Simply, use display:inline-block with DIV tag.
div {
display: inline-block;
}
<div align=right>hai</div>
<div align=center>hello</div>
Update
You can even use style attribute like below:
<div style="display:inline-block">hai</div>
<div style="display:inline-block">hello</div>
But, it's not a good practice...
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Well, as the title says: is it consider as bad practice to use empty divs to style the page? of course if it's performance wise(instead of using images for example).
And second question is: is there any difference between div(as block element) and span(as block element) in any term of performance or anything else?
Thanks.
To answer your first question bluntly, yes. If you are resorting to using empty divs to style a page, you need to learn more about the features that CSS provides. Given enough thought, you should be able to set up appropriate margins, or line-heights to make that happen. Or start working on a flexbox layout.
And for your second question, all elements are basically the same. But we appropriate different semantics to provide meaning. Quoted from SO: What is the difference between HTML tags <div> and <span>?:
But in modern HTML all elements are supposed to have meanings: a <p> is a paragraph, an <li> is a list item, etc., and we're supposed to use the right tag for the right purpose -- not like in the old days when we indented using <blockquote> whether the content was a quote or not.
So, what do you do when there is no meaning to the thing you're trying to do? There's no meaning to a 400px-wide column, is there? You just want your column of text to be 400px wide because that suits your design.
For this reason, they added two more elements to HTML: the generic, or meaningless elements <div> and <span>, because otherwise, people would go back to abusing the elements which do have meanings.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have this problem (I think it's quite simple, however, I cannot solve it):
I normally never work with tables (except this one time). I usually code with divs, but I have to use tables this time for an email design ( O normally also don't use the <font> tags etc :P)
Please take a look at the two links below:
http://www.flo-net.org/test1.html page 1
http://www.flo-net.org/test2.html page 2
The difference between the two pages is, that when you add text to the upper row, the bottom left <td> resizes with the text. But I don't want that! That <td> should stay put at 20px like page 2.
Can anyone help me? Sorry if I did not explain it too well.
If the top row is all one piece of the design, set <td colspan="4">, assuming you have 4 columns.